質問編集履歴
3
自分のコードを追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -14,6 +14,7 @@
|
|
14
14
|
### 該当のソースコード
|
15
15
|
|
16
16
|
### 試したこと
|
17
|
+
```java
|
17
18
|
public class Main {
|
18
19
|
public static void main(String[] args) {
|
19
20
|
Scanner sc = new Scanner(System.in);
|
@@ -60,4 +61,6 @@
|
|
60
61
|
//System.out.println("test");
|
61
62
|
}
|
62
63
|
}
|
64
|
+
|
65
|
+
```
|
63
66
|
### 補足情報(FW/ツールのバージョンなど)
|
2
自分のコードを追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,10 +7,57 @@
|
|
7
7
|
|
8
8
|
標準入力で「7777」と入力したら「Four Card」、「1113」と入力したら「Three Card」、「1199」と入力したら「Tow Pair」と表示するプログラムにしたいです。
|
9
9
|
|
10
|
+
特に[1199]や「1991」などの「Tow Pair」判定、そして「Tow Pair」でないと判定された後、どうやって「One Pair」の判定を行えばいいかよくわかりません。
|
11
|
+
|
10
12
|
### 発生している問題・エラーメッセージ
|
11
13
|
|
12
14
|
### 該当のソースコード
|
13
15
|
|
14
16
|
### 試したこと
|
15
|
-
|
17
|
+
public class Main {
|
18
|
+
public static void main(String[] args) {
|
19
|
+
Scanner sc = new Scanner(System.in);
|
20
|
+
int line = sc.nextInt();
|
21
|
+
sc.nextLine();
|
22
|
+
LinkedList<Character> site = new LinkedList<Character>();
|
23
|
+
char first;
|
24
|
+
char second;
|
25
|
+
int count=0;
|
26
|
+
|
27
|
+
while(sc.hasNextLine()){
|
28
|
+
String card = sc.nextLine();
|
29
|
+
for(int i=0; i<card.length(); i++){
|
30
|
+
site.add(card.charAt(i));
|
31
|
+
}
|
32
|
+
first=site.get(0);//一番目のカード番号
|
33
|
+
//一番目のカードと一致する回数を調べる
|
34
|
+
for(char number: site){
|
35
|
+
if(first==number){
|
36
|
+
count+=1;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
//役判定
|
40
|
+
if(count==4){
|
41
|
+
System.out.println("Four Cord");
|
42
|
+
}else if(count==3){
|
43
|
+
System.out.println("Three Card");
|
44
|
+
}else if (count==2){
|
45
|
+
second=site.get(1);//二番目のカード番号
|
46
|
+
for(int i=2; i<4;i++){
|
47
|
+
if(second==site.get(i)){
|
48
|
+
System.out.println("Two Pair");
|
49
|
+
}else if(i==3){
|
50
|
+
System.out.println("One Pair");
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}else{
|
54
|
+
System.out.println("No Pair");
|
55
|
+
}
|
56
|
+
count=0;
|
57
|
+
site.clear();
|
58
|
+
}
|
59
|
+
|
60
|
+
//System.out.println("test");
|
61
|
+
}
|
62
|
+
}
|
16
63
|
### 補足情報(FW/ツールのバージョンなど)
|
1
言語指定を忘れていた。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
初心者です。
|
3
|
-
簡易版のポーカー役判定をどうやれば実現できるかわかりません。
|
3
|
+
javaで簡易版のポーカー役判定をどうやれば実現できるかわかりません。
|
4
4
|
|
5
5
|
前提条件
|
6
6
|
手札は4枚(標準入力で打ち込むだけ、空白なし)。数字は1~9。絵柄はなし。
|