-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProblem7.java
63 lines (48 loc) · 1.34 KB
/
Problem7.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package dimikOJ;
import java.util.Scanner;
public class Problem7 {
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 > 100) {
T = input.nextInt();
}
input.nextLine();
String[] inputs = new String[T];
for (int i = 0; i < T; i++) {
String temp = input.nextLine();
String tempArray[] = temp.trim().split("\\s");
int tempArrayLength = tempArray.length;
boolean flag = true;
for (String string : tempArray) {
long item = Integer.parseInt(string);
if (Math.abs(item) <= 10000000) {
flag = false;
} else if (Math.abs(item) > 10000000) {
flag = true;
break;
}
}
while (tempArrayLength < 1 || tempArrayLength > 100 || flag) {
temp = input.nextLine();
tempArray = temp.trim().split("\\s");
tempArrayLength = tempArray.length;
for (String string : tempArray) {
long item = Integer.parseInt(string);
if (Math.abs(item) <= 10000000) {
flag = false;
} else if (Math.abs(item) > 10000000) {
flag = true;
break;
}
}
}
inputs[i] = temp;
}
input.close();
for (int i = 0; i < inputs.length; i++) {
System.out.println(inputs[i].trim().split("\\s").length);
}
}
}