// ConsoleApplication10.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include <vector>
#include <string>
using namespace std;
//判断是否存在双王
bool judeDoubleJoker(vector<stringcardVec)
{
if (cardVec.size() != 2) return false;
bool result = true;
for (int i = 0;i < cardVec.size();++i)
{
if (cardVec[i] != "16"&&cardVec[i] != "17")
{
result = false;
break;
}
}
return result;
}
//判断是否有炸弹
//输出
void printVec(vector<stringcardVec)
{
for (int i = 0;i < cardVec.size();++i)
{
// cout << cardVec[i] << " ";
//对输入数据的处理
if (cardVec[i] == "11")
{
cout << "J";
if (i != cardVec.size() - 1)
{
cout << " ";
}
}
else if (cardVec[i] == "12")
{
cout << "Q" ;
if (i != cardVec.size() - 1)
{
cout << " ";
}
}
else if (cardVec[i] == "13")
{
cout << "K" ;
if (i != cardVec.size() - 1)
{
cout << " ";
}
}
else if (cardVec[i] == "14")
{
cout << "A" ;
if (i != cardVec.size() - 1)
{
cout << " ";
}
}
else if (cardVec[i] == "15")
{
cout << "2" ;
if (i != cardVec.size() - 1)
{
cout << " ";
}
}
else if (cardVec[i] == "16")
{
cout << "joker" ;
if (i != cardVec.size() - 1)
{
cout << " ";
}
}
else if (cardVec[i] == "17")
{
cout << "JOKER" ;
if (i != cardVec.size() - 1)
{
cout << " ";
}
}
else {
cout << cardVec[i] ;
if (i != cardVec.size() - 1)
{
cout << " ";
}
}
}
}
//处理数据
void pushCardVec(string card,vector<string&vec)
{
//对输入数据的处理
if (card == "J")
{
vec.push_back("11");
}
else if (card == "Q")
{
vec.push_back("12");
}
else if (card == "K")
{
vec.push_back("13");
}
else if (card == "A")
{
vec.push_back("14");
}
else if (card == "2")
{
vec.push_back("15");
}
else if (card == "joker")
{
vec.push_back("16");
}
else if (card == "JOKER")
{
vec.push_back("17");
}
else {
vec.push_back(card);
}
}
//判断大小
void jude(vector<stringcardVec1, vector<stringcardVec2)
{
if (stoi(cardVec1[0]) stoi(cardVec2[0]))
{
printVec(cardVec1);
}
else if (stoi(cardVec1[0]) < stoi(cardVec2[0]))
{
printVec(cardVec2);
}
else
{
cout << "ERROR";
}
}
int main()
{
string card;
vector<stringcardVec1;
vector<stringcardVec2;
int flag = 0;
while (cin>>card)
{
if (card.find('-') >10 && flag==0)
{
//对输入数据的处理
pushCardVec( card, cardVec1);
}
else if (card.find('-') >10 && flag == 1)
{
pushCardVec(card, cardVec2);
}
else
{
string card1=card.substr(0,card.find('-'));
pushCardVec(card1, cardVec1);
string card2=card.substr(card.find('-')+1);
pushCardVec(card2, cardVec2);
flag = 1;
}
}
//cout << "cardVec1:";
//for (int i = 0;i < cardVec1.size();++i)
//{
// cout << cardVec1[i] << " ";
//}
//cout << "carVec1Size:" << cardVec1.size() << endl;
//cout << endl << "cardVec2:";
//for (int i = 0;i < cardVec2.size();++i)
//{
// cout << cardVec2[i] << " ";
//}
//cout << "carVec2Size:" << cardVec2.size() << endl;
//cout << endl<<"最大的数是:";
if (cardVec1.size() == cardVec2.size())
{
jude(cardVec1, cardVec2);
}
else {
if (judeDoubleJoker(cardVec1) == true )
{
printVec(cardVec1);
}
else if (judeDoubleJoker(cardVec2) == true || cardVec2.size() == 4)
{
printVec(cardVec2);
}
else if (cardVec1.size() == 4)
{
printVec(cardVec1);
}else if (cardVec2.size() == 4)
{
printVec(cardVec2);
}
else
{
cout << "ERROR";
}
}
return 0;
};