質問編集履歴
5
ソースの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -112,7 +112,7 @@
|
|
112
112
|
|
113
113
|
}
|
114
114
|
|
115
|
-
List<Integer> result = new ArrayList<>();
|
115
|
+
List<Integer> result = new ArrayList<Integer>();
|
116
116
|
|
117
117
|
for(int a : answer){
|
118
118
|
|
4
ソース修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -112,7 +112,7 @@
|
|
112
112
|
|
113
113
|
}
|
114
114
|
|
115
|
-
List<Integer> result = new ArrayList<
|
115
|
+
List<Integer> result = new ArrayList<>();
|
116
116
|
|
117
117
|
for(int a : answer){
|
118
118
|
|
3
前提と実現の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
|
3
|
-
乱数と入力した4桁の数字の配列をfor文で回して同じ桁に同じ数字がある場合〇違う桁に同じ数字がある場合△と
|
3
|
+
乱数と入力した4桁の数字の配列をfor文で回して同じ桁に同じ数字がある場合〇違う桁に同じ数字がある場合△となるプログラムを作りたいのですがforまでいかず
|
4
4
|
|
5
|
-
|
5
|
+
数字を入力して無限ループになります
|
6
6
|
|
7
7
|
|
8
8
|
|
2
ソースを修正しコンパイルは通るのですが入力から先に行けず無限ループになってしまいます
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,11 +26,13 @@
|
|
26
26
|
|
27
27
|
|
28
28
|
|
29
|
-
public class MathGame
|
29
|
+
public class MathGame {
|
30
30
|
|
31
31
|
|
32
32
|
|
33
33
|
public static void main(String[] args) {
|
34
|
+
|
35
|
+
// TODO 自動生成されたメソッド・スタブ
|
34
36
|
|
35
37
|
System.out.println("ゲームを始めます");
|
36
38
|
|
@@ -78,7 +80,7 @@
|
|
78
80
|
|
79
81
|
|
80
82
|
|
81
|
-
int
|
83
|
+
int input[] = new int[4];
|
82
84
|
|
83
85
|
boolean validated = false;
|
84
86
|
|
@@ -86,13 +88,13 @@
|
|
86
88
|
|
87
89
|
int a = 0;
|
88
90
|
|
89
|
-
for (int n = 0; a <
|
91
|
+
for (int n = 0; a < input.length; a++) {
|
90
92
|
|
91
93
|
System.out.println("4文字の数字を入力してください");
|
92
94
|
|
93
|
-
String
|
95
|
+
String sc = new Scanner(System.in).nextLine();
|
94
96
|
|
95
|
-
if (
|
97
|
+
if (sc.length() == 4) {
|
96
98
|
|
97
99
|
System.out.println("4文字だけ入力されました。");
|
98
100
|
|
@@ -102,62 +104,42 @@
|
|
102
104
|
|
103
105
|
System.out.println("4文字だけ入力してください。");
|
104
106
|
|
107
|
+
break;
|
108
|
+
|
105
109
|
}
|
106
110
|
|
107
|
-
List<String> reList = new ArrayList<String>();
|
108
|
-
|
109
|
-
for(int r : answer ){
|
110
|
-
|
111
|
-
for(String b : input)
|
112
|
-
|
113
|
-
if(a.equals(b)){
|
114
|
-
|
115
|
-
result .add(a);
|
116
|
-
|
117
|
-
|
111
|
+
}
|
118
112
|
|
119
113
|
}
|
120
114
|
|
115
|
+
List<Integer> result = new ArrayList<Integer>();
|
116
|
+
|
117
|
+
for(int a : answer){
|
118
|
+
|
119
|
+
for(int b : input){
|
120
|
+
|
121
|
+
if(a == b){
|
122
|
+
|
123
|
+
result.add(a);
|
124
|
+
|
121
|
-
|
125
|
+
break;
|
122
126
|
|
123
127
|
}
|
124
128
|
|
125
129
|
}
|
126
130
|
|
127
|
-
|
131
|
+
}
|
128
132
|
|
129
|
-
|
133
|
+
System.out.println("ListA = " + answer);
|
130
134
|
|
135
|
+
System.out.println("ListB = " + input);
|
136
|
+
|
131
|
-
|
137
|
+
System.out.println("ListC = " + result);
|
138
|
+
|
139
|
+
}
|
132
140
|
|
133
141
|
}
|
134
|
-
|
135
|
-
}
|
136
|
-
|
137
|
-
}
|
138
142
|
|
139
143
|
|
140
144
|
|
141
145
|
```
|
142
|
-
|
143
|
-
```
|
144
|
-
|
145
|
-
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
|
146
|
-
|
147
|
-
java.lang.Iterable の配列またはインスタンスのみ繰り返すことができます
|
148
|
-
|
149
|
-
equals(String) を基本タイプ int で起動できません
|
150
|
-
|
151
|
-
result を解決できません
|
152
|
-
|
153
|
-
b を変数に解決できません
|
154
|
-
|
155
|
-
result を変数に解決できません
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
at game.MathGame.main(MathGame.java:50)
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
```
|
1
コンパイルエラーです
test
CHANGED
File without changes
|
test
CHANGED
@@ -136,4 +136,28 @@
|
|
136
136
|
|
137
137
|
}
|
138
138
|
|
139
|
+
|
140
|
+
|
139
141
|
```
|
142
|
+
|
143
|
+
```
|
144
|
+
|
145
|
+
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
|
146
|
+
|
147
|
+
java.lang.Iterable の配列またはインスタンスのみ繰り返すことができます
|
148
|
+
|
149
|
+
equals(String) を基本タイプ int で起動できません
|
150
|
+
|
151
|
+
result を解決できません
|
152
|
+
|
153
|
+
b を変数に解決できません
|
154
|
+
|
155
|
+
result を変数に解決できません
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
at game.MathGame.main(MathGame.java:50)
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
```
|