解题思路:
注意事项:
参考代码:
#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 人评分
2004年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:1327 |
C语言训练-亲密数 (C语言代码)浏览:682 |
a+b浏览:432 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:784 |
简单的a+b (C语言代码)浏览:543 |
图形输出 (C语言代码)浏览:937 |
输入输出格式练习 (C语言代码)浏览:842 |
简单的a+b (C语言代码)浏览:818 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:662 |
C语言程序设计教程(第三版)课后习题9.2 (C语言代码)浏览:606 |