Java Stdin and Stdout I (Hackerrank) Solution: (জাভা স্ট্যান্ডার্ড ইনপুট আউটপুট)

Problem 1:

Most HackerRank challenges require you to read input from stdin (standard input) and write output to stdout (standard output).
One popular way to read input from stdin is by using the Scanner class and specifying the Input Stream as System.in.
Alternatively, you can use the BufferedReader class.

Task
In this challenge, you must read integers from stdin and then print them to stdout. Each integer must be printed on a new line. To make the problem a little easier, a portion of the code is provided for you in the editor below.

Input Format
There are lines of input, and each line contains a single integer.

Sample Input

42 100 125 


Sample Output


42 100 125


Solution:

import java.util.*;

public class Solution {

public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
scan.close();
System.out.println(a);
System.out.println(b);
System.out.println(c);
}
}

No comments:

Post a Comment