题解
2023-07-07 11:40:18
发布于:上海
32阅读
0回复
0点赞
#include<iostream>
#include<stack>
#include<algorithm>
using namespace std;
int a[105];
int main(){
int n;
string m;
cin>>n;
for(int i=0;i<n;i++){
cin>>m;
if(m=="J" ){
a[i]=11;
}else if(m=="Q"){
a[i]=12;
}else if(m=="K"){
a[i]=13;
}
else if(m=="A"){
a[i]=14;
}else if(m=="2"){
a[i]=15;
}
else if(m=="Joker"){
a[i]=100;
}else if(m=="10"){
a[i]=10;
}
else{
char s = m[0];
a[i]=s-48;
}
}
sort(a,a+n);
for(int i=0;i<n;i++){
if(a[i]==11){
cout<<"J"<<endl;
}else if(a[i]==12){
cout<<'Q'<<endl;
}else if(a[i]==13){
cout<<'K'<<endl;
}
else if(a[i]==14){
cout<<'A'<<endl;
}else if(a[i]==15){
cout<<2<<endl;
}else if(a[i]==100){
cout<<"Joker"<<endl;
}else{
cout<<a[i]<<endl;
}
}
return 0;
}
这里空空如也
有帮助,赞一个