Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.util.Scanner;
- public class Lab1 {
- public static void main(String[] args) throws FileNotFoundException {
- int n = 0;
- String line = "";
- String result = "";
- // scan file
- Scanner scanner = new Scanner(System.in);
- // save the number
- n = scanner.nextInt();
- // check if n is between 2 and 10000
- if (n>=2 && n<=10000) {
- // loop n times
- for (int i=1; i<=n; i++) {
- // scan next line
- line = scanner.next();
- // remove white space
- line = line.replaceAll("\\s+","");
- // match if line contains a-z
- if (line.matches("^[a-z]+$")) {
- result += line;
- }
- }
- // print line
- System.out.print(result);
- }
- scanner.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement