title: How do I handle input/ouput format in competitive programming sites like SPOJ?
body: <p>The solution format of most problems are<br>
  1) Input no of test cases<br>
  2) Give the 'test cases' number of input<br>
  3) output answer for each test case at once  </p>
  
  <pre><code>Example  
  3(Total test cases)  
  12 3( test case 1)  
  32 4( test case 2)  
  65 1(test case 3)  
  
  output:  
  4(solution to test case1)  
  3(sol to tc2)
  8(sol to tc3)
  </code></pre>
  
  <p>Once I calculate the answer of each test case, do I need to store it somewhere until all test cases are over and then display the answer line by line?  </p>
  
  <p>If I am thinking correctly, I should be using arrays to store solution to each test case and then display the array at the end. The alternative solution, enter test case and print the solution is something I've got. but that doesn't seem to be accepted in online judge. How do I handle this in c/c++. In python it should be simple.</p>