質問編集履歴
1
test
CHANGED
File without changes
|
test
CHANGED
@@ -15,89 +15,3 @@
|
|
15
15
|
答えではなくヒントといいますか手引きをしてほしいです
|
16
16
|
|
17
17
|
よろしくお願いします
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
```lang-<JAVA>
|
22
|
-
|
23
|
-
import java.util.Scanner;
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
public class hitblow {
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
public static void main(String[] args) {
|
32
|
-
|
33
|
-
int[] ans = new int[4];
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
do {
|
38
|
-
|
39
|
-
for(int i = 0; i < 4; i++)
|
40
|
-
|
41
|
-
ans[i] = (int)(Math.random() * 9) + 1;
|
42
|
-
|
43
|
-
} while(ans[0] == ans[1] || ans[0] == ans[2] || ans[0] == ans[3] || ans[1] == ans[2] || ans[1] == ans[3] || ans[2] == ans[3]);
|
44
|
-
|
45
|
-
for (int i = 0; i < 4; i++){
|
46
|
-
|
47
|
-
//テストなので今は表示
|
48
|
-
|
49
|
-
System.out.print(ans[i]);
|
50
|
-
|
51
|
-
}
|
52
|
-
|
53
|
-
System.out.println();
|
54
|
-
|
55
|
-
//あまりのやつ
|
56
|
-
|
57
|
-
int t_much;
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
Scanner sc = new Scanner(System.in);
|
62
|
-
|
63
|
-
int[] num = new int[5];
|
64
|
-
|
65
|
-
num[0] = sc.nextInt();
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
num[1] = num[0] / 1000;
|
70
|
-
|
71
|
-
t_much = num[0] % 1000;
|
72
|
-
|
73
|
-
num[2] = t_much / 100;
|
74
|
-
|
75
|
-
t_much = t_much % 100;
|
76
|
-
|
77
|
-
num[3] = t_much / 10;
|
78
|
-
|
79
|
-
t_much = t_much % 10;
|
80
|
-
|
81
|
-
num[4] = t_much;
|
82
|
-
|
83
|
-
if(num[1] == ans[0] && num[2] == ans[1] && num[3] == ans[2] && num[4] == ans[3]){
|
84
|
-
|
85
|
-
System.out.println("OK");
|
86
|
-
|
87
|
-
}else{
|
88
|
-
|
89
|
-
System.out.println("bat");
|
90
|
-
|
91
|
-
}
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
}
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
}
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
```
|