解题思路:
注意事项:
参考代码:
#include<iostream> #include<cstdio> #include<string> #include<set> using namespace std; struct node { char a; char b; int c; bool operator<(const node &next) const { return c<next.c; } }; char am[8]={'J','Q','K','A','d','c','h','s'}; char sm[128]; string str; multiset<node> ms; int main() { int j=1; node ts; for(int i='1';i<='9';i++,j++) sm[i]=j; for(int i=0;i<8;i++,j++) sm[am[i]]=j; cin>>str; for(int i=0;i<str.size();i+=2) { ts.a=str[i]; ts.b=str[i+1]; ts.c= sm[ts.a]+sm[ts.b]; ms.insert(ts); } int k=str.size()/2-1; for(multiset<node>::iterator it=ms.begin();it!=ms.end();it++) { if(k--) cout<<it->a <<it->b <<" "; else cout<<it->a <<it->b; } cout<<endl; return 0; }
0.0分
0 人评分
人见人爱A+B (C语言代码)浏览:789 |
校门外的树 (C语言代码)浏览:1122 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:556 |
C语言程序设计教程(第三版)课后习题8.5 (C语言代码)浏览:584 |
【计算两点间的距离】 (C语言代码)浏览:883 |
C语言程序设计教程(第三版)课后习题10.7 (C语言代码)浏览:544 |
C语言程序设计教程(第三版)课后习题6.11 (C语言代码)浏览:2080 |
DNA (C语言描述,数据结构)浏览:855 |
C语言程序设计教程(第三版)课后习题10.4 (C语言代码)浏览:549 |
Cylinder (C语言描述,蓝桥杯)浏览:1247 |