Java Stdin and Stdout I

Sort by

recency

|

570 Discussions

|

  • + 1 comment

    test

  • + 0 comments

    while(scan.hasNextInt()){ int a = scan.nextInt(); System.out.println(a); }

  • + 0 comments

    //What is up, this is my second HackerRank thing, hope y'all like dis.

    import java.util.*;

    public class Solution {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        // Complete this line
        int b = scanner.nextInt();
        // Complete this line
        int c = scanner.nextInt();
    
        System.out.println(a);
        // Complete this line
        System.out.println(b);
        // Complete this line
        System.out.println(c);
    }
    

    }

  • + 0 comments

    //i did like this

    import java.util.Scanner;

    public class Solution {

    public static void main(String[] args) {
    
        Scanner sc = new Scanner(System.in);
    
    
        String value =  sc.nextLine();
        System.out.println(value);
    
    
        String value1 =  sc.nextLine();
        System.out.println(value1);
    
    
        String value2 =  sc.nextLine();
        System.out.println(value2);
    
        sc.close();
    }
    

    }

  • + 0 comments

    import java.io.*;

    public class Main { public static void main(String[] args) throws IOException { // Create a BufferedReader to read from stdin BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        // Read the number of integers
        int n = Integer.parseInt(reader.readLine());  // Read the first line and convert it to an integer
    
        // Loop to read and print each integer
        for (int i = 0; i < n; i++) {
            int num = Integer.parseInt(reader.readLine());  // Read each integer and parse it
            System.out.println(num);  // Print the integer on a new line
        }
    
        // Close the reader
        reader.close();
    }
    

    }