質問編集履歴
3
文法の修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
int a = 0;
|
12
12
|
int count = 0;
|
13
13
|
|
14
|
-
while(a <
|
14
|
+
while(a < 6){
|
15
15
|
s[a] = Integer.parseInt(br.readLine());
|
16
16
|
a += 1;
|
17
17
|
}
|
@@ -30,5 +30,5 @@
|
|
30
30
|
}
|
31
31
|
}
|
32
32
|
```
|
33
|
-
|
33
|
+
6つのサイコロを投げます。その中から三つの目を選んで足して、指定した数値(int dice)になるのは何通りあるか調べたいです。
|
34
34
|
上のようなソースを書いたのですが、重複も含まれてしまうので重複の省き方を知りたいです。
|
2
ソースの変更
title
CHANGED
File without changes
|
body
CHANGED
@@ -16,9 +16,9 @@
|
|
16
16
|
a += 1;
|
17
17
|
}
|
18
18
|
|
19
|
-
for(int i = 0; i <
|
19
|
+
for(int i = 0; i < 3; i++){
|
20
|
-
for(int j = 0; j <
|
20
|
+
for(int j = 0; j < 3; j++){
|
21
|
-
for(int k = 0; k <
|
21
|
+
for(int k = 0; k < 3; k++){
|
22
22
|
int sum = s[i] + s[j] + s[k];
|
23
23
|
if(sum == dice ){
|
24
24
|
count += 1;
|
1
ソースコードのミス
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
public static void main(String[] args) throws Exception {
|
8
8
|
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
9
9
|
int dice = Integer.parseInt(br.readLine());
|
10
|
-
int[] s = new int[
|
10
|
+
int[] s = new int[3];
|
11
11
|
int a = 0;
|
12
12
|
int count = 0;
|
13
13
|
|