Hello,
I have seen many problems that inputs an unknown size of tests and i have to output the result of each test.

An example is here:

The Input

The input will consist of a series of pairs of integers i and j, one pair of integers per line. All integers will be less than 1,000,000 and greater than 0.

You should process all pairs of integers and for each pair determine the maximum cycle length over all integers between and including i and j.

You can assume that no operation overflows a 32-bit integer.

The Output

For each pair of input integers i and j you should output i, j, and the maximum cycle length for integers between and including i and j. These three numbers should be separated by at least one space with all three numbers on one line and with one line of output for each line of input. The integers i and j must appear in the output in the same order in which they appeared in the input and should be followed by the maximum cycle length (on the same line).

Sample Input

1 10
100 200
201 210
900 1000

Sample Output

1 10 20
100 200 125
201 210 89
900 1000 174

Do you know how can i program an input like this?

I would use a struct called 'intPair' or something ...

With me the struct would look like:

struct intPair
{
	int pair[2];
};

Then you're creating a table of structs: intPair input[3]; (now 'input' will be capable to hold three pairs of integers)

You can access the data like this:

// This example shows you how to set the first pair:

input[0].pair[0] = 10;
input[0].pair[1] = 20;

well i kinda didnt undestand ur problem
wat does the following mean

You should process all pairs of integers and for each pair determine the maximum cycle length over all integers between and including i and j.

if u could be a little more explicit about it , i think we can work it out.

besides to input pair u can create a class
like

class   abc
{
          float i ,j;
          float maxlen ;
          public :
          abc()
          {   i=j=0;
          }
          void maxlen ()
          {
          --------------------
           ----------------
           }
            void disp ()
           {
            cout<<i<<setw(5)<<j<<setw(5)<<maxlen;
           }

};

void main ()
{
       abc a[100] ; // or how many ever pair of nos u want 
                         // then accept those pair of nos using for loop
                         // at same time call the maxlen function which 
                         // calculates watever u want( srry couldnt    undestand that part )
                       // then all that u have to do is display 
}

well i guess this can give you a rough idea .

You should process all pairs of integers and for each pair determine the maximum cycle length over all integers between and including i and j.

What do they actually mean by that ?

Well, since there is an unknown size of tests, if you are reading the input from an ifstream, you can use ios::eof() to see if the file is empty.... i'm not sure if that works for cin though...

You can also use while(cin>>something); (where something is a numeric datatype)
This instruction will read numbers until a non-numeric value was given ...

You can also use while(cin>>something); (where something is a numeric datatype)
This instruction will read numbers until a non-numeric value was given ...

The while (cin>>something) solved the problem.
Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.