Problem
http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=20772
Thinking
TODO
Solution
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int POKER_PRIORITY[14] = {-1,12,13,1,2,3,4,5,6,7,8,9,10,11};
bool comp(int a,int b)
{
return POKER_PRIORITY[a] > POKER_PRIORITY[b];
}
int main()
{
int face;
vector<int> cards;
while(cin >> face)
{
if(face == 0)
break;
cards.push_back(face);
}
sort(cards.begin(),cards.end(),comp);
for(vector<int>::iterator it = cards.begin() ; it != cards.end() ; ++it)
{
if(*it == 13)
cout << "K" << endl;
else if(*it == 12)
cout << "Q" << endl;
else if(*it == 11)
cout << "J" << endl;
else
cout << *it << endl;
}
return 0;
}