MCPcopy Create free account
hub / github.com/Hazrat-Ali9/Computer-Programming / main

Method main

Problem2.java:7–50  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

5public class Problem2 {
6
7 public static void main(String[] args) {
8 // TODO Auto-generated method stub
9 Scanner scan = new Scanner(System.in);
10 int[] numberCount;
11 int N;
12 String line;
13 String[] numbersInALineStr;
14 int[] numbersInALineStrInt;
15
16 N = scan.nextInt();
17 scan.nextLine();
18 numberCount = new int[N];
19
20 for (int i = 0; i < N; i++) {
21 line = scan.nextLine();
22
23 numbersInALineStr = line.trim().split("\\s+");
24 numbersInALineStrInt = new int[numbersInALineStr.length];
25
26 for (int j = 0; j < numbersInALineStr.length; j++) {
27 numbersInALineStrInt[j] = Integer.parseInt(numbersInALineStr[j]);
28 }
29
30 for (int number : numbersInALineStrInt) {
31 while (Math.abs(number) > 10000000) {
32 line = scan.nextLine();
33
34 numbersInALineStr = line.trim().split("\\s+");
35 numbersInALineStrInt = new int[numbersInALineStr.length];
36
37 for (int j = 0; j < numbersInALineStr.length; j++) {
38 numbersInALineStrInt[j] = Integer.parseInt(numbersInALineStr[j]);
39 }
40 }
41 }
42 numberCount[i] = numbersInALineStrInt.length;
43 }
44 scan.close();
45
46 for (int number : numberCount) {
47 System.out.printf("%d\n", number);
48 }
49
50 }
51
52}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected