質問編集履歴
3
修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -64,7 +64,7 @@
|
|
64
64
|
|
65
65
|
public class check {
|
66
66
|
|
67
|
-
public static
|
67
|
+
public static boolean check(String line){
|
68
68
|
|
69
69
|
|
70
70
|
|
@@ -74,13 +74,13 @@
|
|
74
74
|
|
75
75
|
if (1 <= number && number <= 9) {
|
76
76
|
|
77
|
-
return
|
77
|
+
return true;
|
78
78
|
|
79
79
|
}
|
80
80
|
|
81
81
|
else {
|
82
82
|
|
83
|
-
return
|
83
|
+
return false;
|
84
84
|
|
85
85
|
|
86
86
|
|
@@ -138,18 +138,6 @@
|
|
138
138
|
|
139
139
|
int num = a[n][m];
|
140
140
|
|
141
|
-
if (num % 3 == 0){
|
142
|
-
|
143
|
-
System.out.println(num+"!?");
|
144
|
-
|
145
|
-
}
|
146
|
-
|
147
|
-
else{
|
148
|
-
|
149
|
-
System.out.println(num);
|
150
|
-
|
151
|
-
}
|
152
|
-
|
153
141
|
|
154
142
|
|
155
143
|
|
2
ソースの追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,41 +24,129 @@
|
|
24
24
|
|
25
25
|
といった感じで作ろうと考えています。
|
26
26
|
|
27
|
-
|
27
|
+
どなたか教えてくれませんでしょうか?
|
28
28
|
|
29
|
-
|
29
|
+
現状このような感じです。
|
30
30
|
|
31
|
-
ど
|
31
|
+
参考にしたいので回答例などもあると助かります
|
32
32
|
|
33
33
|
|
34
34
|
|
35
35
|
```Java
|
36
36
|
|
37
|
-
public class
|
37
|
+
public class main {
|
38
38
|
|
39
|
-
public static void
|
39
|
+
public static void main(String[] args) throws IOException {
|
40
40
|
|
41
|
-
|
41
|
+
try{
|
42
|
+
|
43
|
+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
44
|
+
|
45
|
+
String line = br.readLine();
|
46
|
+
|
47
|
+
Inputdatacheck.check(line);
|
48
|
+
|
49
|
+
Multiplation.kuku(line);
|
50
|
+
|
51
|
+
}catch(NumberFormatException e){
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
check
|
64
|
+
|
65
|
+
public class check {
|
66
|
+
|
67
|
+
public static int check(String line){
|
68
|
+
|
69
|
+
|
42
70
|
|
43
71
|
try {
|
44
72
|
|
45
|
-
num = Integer.parseInt(n
|
73
|
+
int number = Integer.parseInt(line);
|
46
74
|
|
47
|
-
|
75
|
+
if (1 <= number && number <= 9) {
|
48
76
|
|
49
|
-
|
77
|
+
return number;
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
else {
|
82
|
+
|
83
|
+
return -1;
|
50
84
|
|
51
85
|
|
52
86
|
|
53
|
-
|
87
|
+
}
|
54
88
|
|
55
|
-
|
89
|
+
} catch (NumberFormatException e)
|
90
|
+
|
91
|
+
{
|
92
|
+
|
93
|
+
throw new NumberFormatException("error");
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
56
98
|
|
57
99
|
}
|
58
100
|
|
59
|
-
throw new IllegalArgumentException("パラメータが1以上、9以下ではありません。設定されている値は" + number + "です。");
|
60
101
|
|
61
102
|
|
103
|
+
}
|
104
|
+
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
keisan
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
public class keisan {
|
114
|
+
|
115
|
+
public static void kuku(String line){
|
116
|
+
|
117
|
+
int [][] a ;
|
118
|
+
|
119
|
+
int n = Integer.parseInt(line);
|
120
|
+
|
121
|
+
int m = Integer.parseInt(line);
|
122
|
+
|
123
|
+
a = new int[n][m];
|
124
|
+
|
125
|
+
int kuku[][] = new int[9][9];
|
126
|
+
|
127
|
+
for( int i=0; i<9; i++ ){
|
128
|
+
|
129
|
+
for( int j=0; j<9; j++ ){
|
130
|
+
|
131
|
+
kuku[i][j] = (i+1) * (j+1);
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
a[n][m] =kuku[n][m];
|
138
|
+
|
139
|
+
int num = a[n][m];
|
140
|
+
|
141
|
+
if (num % 3 == 0){
|
142
|
+
|
143
|
+
System.out.println(num+"!?");
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
else{
|
148
|
+
|
149
|
+
System.out.println(num);
|
62
150
|
|
63
151
|
}
|
64
152
|
|
@@ -70,6 +158,6 @@
|
|
70
158
|
|
71
159
|
}
|
72
160
|
|
73
|
-
|
161
|
+
}
|
74
162
|
|
75
163
|
```
|
1
できているところ
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,8 +24,52 @@
|
|
24
24
|
|
25
25
|
といった感じで作ろうと考えています。
|
26
26
|
|
27
|
-
入力値チェッククラス
|
27
|
+
入力値チェッククラスある程度解くことができました。
|
28
28
|
|
29
29
|
しかし、九九の二次元配列で結果を取得するクラスが悩んでも解けません。
|
30
30
|
|
31
31
|
どなたか教えてくれませんでしょうか?
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
```Java
|
36
|
+
|
37
|
+
public class Inputdatacheck {
|
38
|
+
|
39
|
+
public static void check(number){
|
40
|
+
|
41
|
+
int num;
|
42
|
+
|
43
|
+
try {
|
44
|
+
|
45
|
+
num = Integer.parseInt(number);
|
46
|
+
|
47
|
+
} catch (NumberFormatException e) {
|
48
|
+
|
49
|
+
throw new NumberFormatException(" パラメータが半角数字ではありません。設定されている値は" + number + "です。");
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
if (1 <= num && num <= 9) {
|
54
|
+
|
55
|
+
return num;
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
throw new IllegalArgumentException("パラメータが1以上、9以下ではありません。設定されている値は" + number + "です。");
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
}
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
```
|