c++ - Creating X Number of Nameless Objects -
In many online judge problems, the format for input is as follows: Let's say X is the number of test cases. After that X lines are the conditions for each test case.
In the example below, there are two test cases. Each test case specifies the upper and lower bound, for which the output should be shown.
Input: 2 1 10 3 5 Output: 2 3 5 7 3 5
Now for my question, my program has a test case Can handle by:
int main () {TestCase t; T.setRange (); T.compute (); T.print (); }
How can I make X Test Cases without all those 'T' names?
X is specified at the ram time.
You can std :: vector & lt; Testcase & gt; Allofem;
and allofem.push_back (TestCase ())
X
bar; #include & lt; Vector & gt;
Remember, of course. You can then loop over allofem
and count on each item and then print it.
Comments
Post a Comment