Introduction Solution

Congratulations on finishing your first problem. If you haven't finished, I recommend going back. That doesn't mean there's anything wrong with looking at the solution. Just make sure it's your last option. We'll need that template from the first text to finish this problem. After that we'll use Scanner to take in each line and then print them out.

import java.io.*;
import java.util.*;

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

        int T = in.nextInt(); // number of lines
        in.nextLine(); // Since in.nextLine takes in a line, it will pick up the end of the line after 3
                       // If we didn't have this line then there would be a blank line at the beginning
        for (int tc = 0; tc < T; tc++) { // run each data set with a for loop (if you don't know for loops go research
                                         // or ask for help)
            String line = in.nextLine();
            System.out.println(line); // output each data set
        }
    }
}

Don't ever feel bad if you get stuck. Don't worry we've all been there. Even the best of us have been there. Hey I got stuck on the beginner problems when I first started, and they still thought I was smart and you ARE too. You WILL get stuck. It only depends on whether you quit or not.

results matching ""

    No results matching ""