Advertisement
Guest User

Untitled

a guest
Nov 20th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. import java.io.FileNotFoundException;
  2. import java.io.FileReader;
  3. import java.util.Scanner;
  4.  
  5.  
  6. public class Lab1 {
  7.    
  8.      public static void main(String[] args) throws FileNotFoundException {
  9.          
  10.          int n = 0;
  11.          String line = "";
  12.          String result = "";
  13.          
  14.          // scan file
  15.          Scanner scanner = new Scanner(System.in);
  16.          
  17.          // save the number
  18.          n = scanner.nextInt();
  19.        
  20.          // check if n is between 2 and 10000
  21.          if (n>=2 && n<=10000) {
  22.              
  23.              // loop n times
  24.              for (int i=1; i<=n; i++) {
  25.                  
  26.                  // scan next line
  27.                  line = scanner.next();
  28.  
  29.                  // remove white space
  30.                  line = line.replaceAll("\\s+","");
  31.                  
  32.                  // match if line contains a-z
  33.                  if (line.matches("^[a-z]+$")) {
  34.                      
  35.                      result += line;                     
  36.                  }
  37.                  
  38.              }
  39.             // print line
  40.              System.out.print(result);
  41.              
  42.          }
  43.  
  44.          scanner.close();
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement