Reading inputs in java
- by Gandalf StormCrow
Hello everyone I'm trying to improve my Java skills by solving some problems from ACM, now the thing is my sample input looks like this :
3 100
34 100
75 250
27 2147483647
101 304
101 303
-1 -1
So at first I'm just trying to read them but its not working here is the java code:
import java.io.BufferedInputStream;
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner stdin = new Scanner(new BufferedInputStream(System.in));
while (stdin.hasNext()) {
System.out.println(stdin.nextInt() + " and the next " + stdin.nextInt());
}
}
}
I'm trying to send these inputs as an argument, and not by reading them from file, here is how:
The program just spins(executes) but not printing anything. How can I fix this?