-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathccc01s1.cpp
52 lines (49 loc) · 1.05 KB
/
ccc01s1.cpp
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
#include <bits/stdc++.h>
using namespace std;
int calc(vector<char> &cur)
{
int ret = 0;
if (cur.size() == 0)
ret += 3;
else if (cur.size() == 1)
ret += 2;
else if (cur.size() == 2)
ret += 1;
for (auto &x : cur)
{
switch(x)
{
case 'A': ret++;
case 'K': ret++;
case 'Q': ret++;
case 'J': ret++;
}
}
return ret;
}
int main()
{
string n;
cin>>n;
map<char,vector<char>> cards;
char t = '0';
for (auto &x : n)
{
if (x == 'C' || x == 'D' || x == 'H' || x == 'S')
t = x;
else
cards[t].push_back(x);
}
int tot = 0, cur = 0;
printf("Cards Dealt Points\n");
for (auto &x : vector<string>({"Clubs", "Diamonds", "Hearts", "Spades"}))
{
printf("%s", x.c_str());
for (auto &y : cards[x[0]])
printf(" %c", y);
cur = calc(cards[x[0]]);
printf(" %i\n", cur);
tot += cur;
}
printf("Total %i\n", tot);
}