Actually it doesn't answer the question completely(why your code isn't working) but you may use following code.
int n = Integer.parseInt(readInput.readLine());
for(int i = 0; i < n; ++i) {
String line = readInput().readLine();
// use line here
}
As for me it's more readable and even may save your time in such rare cases when testcases are incorrect(with extra info at the end of file)
BTW, seems you take part in some programming competition. Make note, that Scanner may be quite slow to input a lot of data. you may consider using BufferedReader
with possible StringTokenizer
(not needed in this task)
No comments:
Post a Comment