-
Notifications
You must be signed in to change notification settings - Fork 0
/
Problem24.java
39 lines (32 loc) · 1013 Bytes
/
Problem24.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package dimikOJ;
import java.util.Scanner;
public class Problem24 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
int T = input.nextInt();
while (T < 1) {
T = input.nextInt();
}
input.nextLine();
String[] lines = new String[T];
for (int i = 0; i < lines.length; i++) {
int length = input.nextInt();
String temp = input.nextLine();
int tempLength = temp.trim().replaceAll("\\s{2,}", " ").split("\\s").length;
while (length != tempLength) {
temp = input.nextLine();
tempLength = temp.trim().replaceAll("\\s{2,}", " ").split("\\s").length;
}
lines[i] = temp.trim().replaceAll("\\s{2,}", " ");
}
input.close();
for (int i = 0; i < lines.length; i++) {
String[] tempArray = lines[i].split("\\s");
for (int j = 0; j < tempArray.length; j += 2) {
System.out.print(Integer.parseInt(tempArray[j]) + " ");
}
System.out.println();
}
}
}