-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKarte.java
More file actions
88 lines (79 loc) · 2.39 KB
/
Copy pathKarte.java
File metadata and controls
88 lines (79 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import java.util.Scanner;
import java.text.DecimalFormat;
import java.lang.Math;
import java.lang.Integer;
public class Karte {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
boolean[] p = new boolean[14];
boolean[] k = new boolean[14];
boolean[] h = new boolean[14];
boolean[] t = new boolean[14];
for (int i = 0; i < 14; i++) {
p[i] = false;
k[i] = false;
h[i] = false;
t[i] = false;
}
boolean error = false;
int pTot = 13;
int kTot = 13;
int hTot = 13;
int tTot = 13;
String s = input.nextLine();
do {
String c = s.substring(0, 3);
String cSuit = c.substring(0, 1);
int cNumb = Integer.parseInt(c.substring(1, 3));
if (cSuit.equals("P")) {
if (!p[cNumb]) {
p[cNumb] = true;
} else {
error = true;
break;
}
} else if (cSuit.equals("K")) {
if (!k[cNumb]) {
k[cNumb] = true;
} else {
error = true;
break;
}
} else if (cSuit.equals("H")) {
if (!h[cNumb]) {
h[cNumb] = true;
} else {
error = true;
break;
}
} else if (cSuit.equals("T")) {
if (!t[cNumb]) {
t[cNumb] = true;
} else {
error = true;
break;
}
}
s = s.substring(3, s.length());
} while (s.length() > 0);
for (int i = 0; i < 14; i++) {
if (p[i]) {
pTot--;
}
if (k[i]) {
kTot--;
}
if (h[i]) {
hTot--;
}
if (t[i]) {
tTot--;
}
}
if (!error) {
System.out.print(pTot + " " + kTot + " " + hTot + " " + tTot);
} else {
System.out.print("GRESKA");
}
}
}