回答編集履歴

5

乱数範囲変更

2020/01/05 04:30

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -26,7 +26,7 @@
26
26
 
27
27
  //千の位を選ぶ
28
28
 
29
- int sen = rand.nextInt(9);
29
+ int sen = rand.nextInt(10);
30
30
 
31
31
  ans[0] = digits[sen];
32
32
 
@@ -36,7 +36,7 @@
36
36
 
37
37
  //百の位を選ぶ
38
38
 
39
- int hyaku = rand.nextInt(8);
39
+ int hyaku = rand.nextInt(9);
40
40
 
41
41
  ans[1] = digits[hyaku];
42
42
 
@@ -46,7 +46,7 @@
46
46
 
47
47
  //十の位を選ぶ
48
48
 
49
- int zyuu = rand.nextInt(7);
49
+ int zyuu = rand.nextInt(8);
50
50
 
51
51
  ans[2] = digits[zyuu];
52
52
 
@@ -56,7 +56,7 @@
56
56
 
57
57
  //一の位を選ぶ
58
58
 
59
- int iti = rand.nextInt(6);
59
+ int iti = rand.nextInt(7);
60
60
 
61
61
  ans[3] = digits[iti];
62
62
 

4

コメント修正

2020/01/05 04:30

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -14,13 +14,13 @@
14
14
 
15
15
  public static void main(String[] args) {
16
16
 
17
- Random rand = new Random();
18
-
19
- //10個の列を作る
17
+ //10個のから4個の数ランダムに選ぶ
20
18
 
21
19
  int[] digits = {0,1,2,3,4,5,6,7,8,9};
22
20
 
23
21
  int[] ans = new int[4];
22
+
23
+ Random rand = new Random();
24
24
 
25
25
 
26
26
 
@@ -62,7 +62,7 @@
62
62
 
63
63
 
64
64
 
65
- //4桁持ってくる
65
+ //選んだ4個の数を表示
66
66
 
67
67
  System.out.println("" + ans[0] + ans[1] + ans[2] + ans[3]);
68
68
 

3

バグ修正

2020/01/05 04:05

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -30,7 +30,7 @@
30
30
 
31
31
  ans[0] = digits[sen];
32
32
 
33
- digits[ans[0]] = digits[9];
33
+ digits[sen] = digits[9];
34
34
 
35
35
 
36
36
 
@@ -40,7 +40,7 @@
40
40
 
41
41
  ans[1] = digits[hyaku];
42
42
 
43
- digits[ans[1]] = digits[8];
43
+ digits[hyaku] = digits[8];
44
44
 
45
45
 
46
46
 
@@ -50,7 +50,7 @@
50
50
 
51
51
  ans[2] = digits[zyuu];
52
52
 
53
- digits[ans[2]] = digits[7];
53
+ digits[zyuu] = digits[7];
54
54
 
55
55
 
56
56
 

2

コード整形

2020/01/05 04:01

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -16,8 +16,6 @@
16
16
 
17
17
  Random rand = new Random();
18
18
 
19
-
20
-
21
19
  //10個の配列を作る
22
20
 
23
21
  int[] digits = {0,1,2,3,4,5,6,7,8,9};
@@ -32,7 +30,7 @@
32
30
 
33
31
  ans[0] = digits[sen];
34
32
 
35
- digits[ans[0]]= digits[9];
33
+ digits[ans[0]] = digits[9];
36
34
 
37
35
 
38
36
 
@@ -42,7 +40,7 @@
42
40
 
43
41
  ans[1] = digits[hyaku];
44
42
 
45
- digits[ans[1]]= digits[8];
43
+ digits[ans[1]] = digits[8];
46
44
 
47
45
 
48
46
 
@@ -52,7 +50,7 @@
52
50
 
53
51
  ans[2] = digits[zyuu];
54
52
 
55
- digits[ans[2]]= digits[7];
53
+ digits[ans[2]] = digits[7];
56
54
 
57
55
 
58
56
 

1

配列確保変更

2020/01/05 03:57

投稿

shiracamus
shiracamus

スコア5406

test CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  int[] digits = {0,1,2,3,4,5,6,7,8,9};
24
24
 
25
- int[] ans = {0,0,0,0};
25
+ int[] ans = new int[4];
26
26
 
27
27
 
28
28