In this HackerRank Java Stdin and Stdout I problem in the java programming language, you must read 3 integers from stdin and then print them to stdout. Each integer must be printed on a new line.
HackerRank Java Stdin and Stdout I problem solution
import java.util.*; public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int a = scan.nextInt(); // Complete this line int b = scan.nextInt(); // Complete this line int c = scan.nextInt(); System.out.println(a); // Complete this line System.out.println(b); // Complete this line System.out.println(c); } }
The solution in Java 8 programming.
import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int a=sc.nextInt(); int b=sc.nextInt(); int c=sc.nextInt(); System.out.println(a); System.out.println(b); System.out.println(c); } }
3 Comments
nice and good
ReplyDeleteyea this website is amazing
ReplyDeleteTengo una solución que también es compatible, intenté usar BufferReader pero da muchÃsima lata al tratar de leer el input separado por \n
ReplyDeletepublic static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while(scanner.hasNext()) {
int a = scanner.nextInt();
System.out.println(a);
}
scanner.close();
}