Page 1 of 1

### Problems input

Posted: Wed Nov 14, 2012 7:37 pm
If I have the following entry:
2

1
-1 0
-5 -3
2 5
0 0

1
-1 0
0 1
0 0

2 \ n \ n1 \ n-1 0 \ n-5 -3 \ n2 5 \ n0 0 \ n \ n1 \ n-1 0 \ n0 1 \ n0 0

### Re: Problems input

Posted: Thu Nov 15, 2012 1:43 am
Which problem number?

### Re: Problems input

Posted: Sun Nov 18, 2012 4:40 pm
2 \ n \ n1 \ n-1 0 \ n-5 -3 \ n2 5 \ n0 0 \ n \ n1 \ n-1 0 \ n0 1 \ n0 0

or should I read several lines?

2

1
-1 0
-5 -3
2 5
0 0

1
-1 0
0 1
0 0

### Re: Problems input

Posted: Mon Nov 19, 2012 11:47 pm
I'm not sure I understand what you're asking. On some problems it is best to parse the input line by line, on others you should read an int at a time.

### Re: Problems input

Posted: Tue Dec 04, 2012 4:29 am
Thanks, I was able to fix the problem, but now I have a new problem with the entry:
if not tell me which is the termination condition, as I know I'll finish the entry?

### Re: Problems input

Posted: Sat Dec 08, 2012 5:42 am
I can't tell you how to parse the input without a problem description.

### Re: Problems input

Posted: Thu Jun 27, 2013 7:11 pm
if you're asking about reading such input terminated by blank lines, that will work even if the last line has NO blank line, just check if the line read is a null string.

sample code:

Code: Select all

``````import java.util.*;
import java.io.*;

public class Main{
public static void main( String args[] ) throws IOException{

String in;
int n = Integer.parseInt( br.readLine() );

br.readLine(); // ignore first blank line

while( n-- != 0 ){
while( ( in = br.readLine() ) != null ){ // will always work even if EOF
// do stuff here
}
}

}
}
``````