質問編集履歴
1
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,47 +6,4 @@
|
|
6
6
|
○2、×2という風にしたいです
|
7
7
|
|
8
8
|
答えではなくヒントといいますか手引きをしてほしいです
|
9
|
-
よろしくお願いします
|
9
|
+
よろしくお願いします
|
10
|
-
|
11
|
-
```lang-<JAVA>
|
12
|
-
import java.util.Scanner;
|
13
|
-
|
14
|
-
public class hitblow {
|
15
|
-
|
16
|
-
public static void main(String[] args) {
|
17
|
-
int[] ans = new int[4];
|
18
|
-
|
19
|
-
do {
|
20
|
-
for(int i = 0; i < 4; i++)
|
21
|
-
ans[i] = (int)(Math.random() * 9) + 1;
|
22
|
-
} 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]);
|
23
|
-
for (int i = 0; i < 4; i++){
|
24
|
-
//テストなので今は表示
|
25
|
-
System.out.print(ans[i]);
|
26
|
-
}
|
27
|
-
System.out.println();
|
28
|
-
//あまりのやつ
|
29
|
-
int t_much;
|
30
|
-
|
31
|
-
Scanner sc = new Scanner(System.in);
|
32
|
-
int[] num = new int[5];
|
33
|
-
num[0] = sc.nextInt();
|
34
|
-
|
35
|
-
num[1] = num[0] / 1000;
|
36
|
-
t_much = num[0] % 1000;
|
37
|
-
num[2] = t_much / 100;
|
38
|
-
t_much = t_much % 100;
|
39
|
-
num[3] = t_much / 10;
|
40
|
-
t_much = t_much % 10;
|
41
|
-
num[4] = t_much;
|
42
|
-
if(num[1] == ans[0] && num[2] == ans[1] && num[3] == ans[2] && num[4] == ans[3]){
|
43
|
-
System.out.println("OK");
|
44
|
-
}else{
|
45
|
-
System.out.println("bat");
|
46
|
-
}
|
47
|
-
|
48
|
-
}
|
49
|
-
|
50
|
-
}
|
51
|
-
|
52
|
-
```
|