Saturday, May 22, 2010

How do I return a range of values from a function in C++?

Need range +/- start/end values


Couldnt fit it all:





#include %26lt;iostream%26gt;


#include %26lt;cmath%26gt;


#include %26lt;string%26gt;


using namespace std;





int start_year, end_year, out_years;





int i = 0;





string proc_year_s(string incl_start_year_f);


string proc_year_e(string incl_end_year_f);


string c_include_s, c_include_e, incl_year_s, incl_year_e, incl_start_year, incl_end_year;





int main( )


{


while(true){


cout %26lt;%26lt; "Leap-Year Calculator\n" %26lt;%26lt; endl;





cout %26lt;%26lt; "Please enter a starting year:\n";


cin %26gt;%26gt; start_year;





cout %26lt;%26lt; "Please enter an ending year:\n";


cin %26gt;%26gt; end_year;





cout %26lt;%26lt; "Include the starting year [y/n]:\n";


cin %26gt;%26gt; incl_start_year;





cout %26lt;%26lt; "Include the ending year [y/n]:\n";





cout %26lt;%26lt; "Here are your leap years between " %26lt;%26lt; start_year %26lt;%26lt; " and " %26lt;%26lt; end_year %26lt;%26lt; proc_year_s(incl_start_year) %26lt;%26lt; start_year %26lt;%26lt; proc_year_e(incl_end_year) %26lt;%26lt; end_year %26lt;%26lt; ":\n"


%26lt;%26lt; out_years;





string ans = "x";


cout %26lt;%26lt; endl %26lt;%26lt; "Pick another range [y/n]:\n";


cin %26gt;%26gt; ans;

How do I return a range of values from a function in C++?
define a struct





typedef struct MyRange


{


int start;


int end;


}





declare in the function





MyRange Function_Get(...)


No comments:

Post a Comment