Echo One Solution

One of the smallest yet biggest feats for a super novice programmer is the mysterious 'white space error'. This typically happens with Scanner (the tool you're using to take in input). It's just simply a mistake you have to make to understand. So kudos to you for making the mistake. And I repeat, even the most advanced programmers will get tripped up over these sneaky guys.

import java.util.*;
import java.io.*;
import static java.lang.System.*;

class Main {
    public static void main (String[] args) throws java.lang.Exception {
        Scanner in = new Scanner(System.in);

        int T = in.nextInt();
        in.nextLine(); // pick up white space
        /* 
         *  white space errors happen when you use in.nextLine() in conjunction with with in.nextInt(),
         *  in.nextDouble(), in.next()
         */
        for(int i = 0; i < T; i++){
            System.out.println(in.nextLine());
        }
    }
}

Okay, so the next problem is unique in its own right. It's like this one but...you'll see.

results matching ""

    No results matching ""