解题思路:
注意事项:
参考代码:
#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 for Input-Output Practice (II) (C语言代码)浏览:999 |
C语言程序设计教程(第三版)课后习题8.3 (C语言代码)浏览:1099 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:476 |
2^k进制数 (C语言描述,蓝桥杯)浏览:1420 |
图形输出 (C语言代码)浏览:945 |
简单的a+b (C语言代码)浏览:630 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:459 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:546 |
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:817 |
IP判断 (C++代码)浏览:754 |