Just re-print the input. There has to be a cooler way to do this in Java. I really want to just pipe the inputstream to the outputstream somehow.
import java.io.PrintWriter;
import java.util.Scanner;
/**
*
* @author Sanchit M. Bhatnagar
* @see http://uhunt.felix-halim.net/id/74004
*
*/
public class P1124 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
while (sc.hasNextLine()) {
out.println(sc.nextLine());
}
out.close();
sc.close();
}
}
why it shows runtime error!!
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.println(sc.nextInt());
}
}
Because the next thing might not be an integer. Scanner blocks until it gets an integer so after possibly timing out, uva probably calls it a runtime error thinking that its maybe an infinite loop in your code or something.
I wrote nextLine() and you are writing nextInt(). Your code won’t even work for the sample test cases provided!