回答編集履歴

1

コメントに合わせて修正

2020/06/21 13:27

投稿

kotori_a
kotori_a

スコア820

test CHANGED
@@ -2,27 +2,25 @@
2
2
 
3
3
  ```
4
4
 
5
- public class Main {
5
+ public class Graph {
6
6
 
7
- public static void main(String[] args) throws Exception {
7
+ public static void main(String[] args) {
8
8
 
9
- System.out.printf("%4d:%n", -10);
9
+ printGraph(10);
10
10
 
11
- System.out.printf("%4d:%n", -9);
11
+ }
12
12
 
13
- System.out.printf("%4d:%n", -8);
13
+
14
14
 
15
- System.out.printf("%4d:%n", 8);
15
+ private static void printGraph(int x) {
16
16
 
17
- System.out.printf("%4d:%n", 9);
17
+ for(int a=-x; a<x+1; a++) {
18
18
 
19
- System.out.printf("%4d:%n", 10);
19
+ System.out.printf("%3d:%n", a);
20
20
 
21
+ }
21
22
 
22
-
23
- System.out.printf("%4d:%s%n", -10, "テスト1");
24
-
25
- System.out.printf("%4d:%s%n", 8, "テスト2");
23
+ System.out.println("");
26
24
 
27
25
  }
28
26
 
@@ -40,20 +38,48 @@
40
38
 
41
39
  ```
42
40
 
43
- -10:
41
+ -10:
44
42
 
45
- -9:
43
+ -9:
46
44
 
47
- -8:
45
+ -8:
48
46
 
49
- 8:
47
+ -7:
50
48
 
51
- 9:
49
+ -6:
52
50
 
53
- 10:
51
+ -5:
54
52
 
55
- -10:テスト1
53
+ -4:
56
54
 
55
+ -3:
56
+
57
+ -2:
58
+
59
+ -1:
60
+
61
+ 0:
62
+
63
+ 1:
64
+
65
+ 2:
66
+
67
+ 3:
68
+
69
+ 4:
70
+
71
+ 5:
72
+
73
+ 6:
74
+
75
+ 7:
76
+
57
- 8:テスト2
77
+ 8:
78
+
79
+ 9:
80
+
81
+ 10:
82
+
83
+
58
84
 
59
85
  ```