Thursday, 25 August 2016

Java program to read N lines of input until you reach EOF

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {
   static String s;
    static int a=1;
    // For loop
public static void main(String[] args) {
   Scanner scan = new Scanner(System.in);
   for(int i = 1; scan.hasNext()== true; i++){
       System.out.println(i + " " + scan.nextLine());
   }
}

}
Post a Comment