Regarding input
Posted: Sun Mar 19, 2006 10:05 pm
Hello, everyone.
What's the best way to read an input file where the test cases are separeted by line breaks or blank lines, instead of having an explicit counter?
Example:
Instead of
The second case has an explicits the number of test cases (2) and each test case explicits the number of input elements (5 and 5).
For the first case, I have been reading the input with fgets into a string and processing its elements with sscanf, but it's quite boring and very little elegant this way. Can anybody share a better alternative?
Thanks in advance![/code]
What's the best way to read an input file where the test cases are separeted by line breaks or blank lines, instead of having an explicit counter?
Example:
Code: Select all
this is test case one
this is test case two
Code: Select all
2
5 this is test case one
5 this is test case two
For the first case, I have been reading the input with fgets into a string and processing its elements with sscanf, but it's quite boring and very little elegant this way. Can anybody share a better alternative?
Thanks in advance![/code]