参考代码:
#include<bits/stdc++.h> using namespace std; int cov(char ch) { if (ch == 'K') return 13; if (ch == 'Q') return 12; if (ch == 'J') return 11; return ch - 48; } int main() { vector<int> Puke; char ch; while (cin >> ch) { if (ch == '0') Puke.pop_back(), Puke.push_back(10); else Puke.push_back(cov(ch)); } if (Puke.size() != 52) { cout << -1 << endl; exit(EXIT_SUCCESS); } vector<int> ans; while (!Puke.empty()) { int now = Puke.front(); Puke.erase(Puke.begin()); if (now >= ans.size()) ans.push_back(now); else ans.insert(ans.begin() + now, now); } for (int pos = 0; pos < 52; pos++) { if (ans[pos] == 13) cout << 'K'; else if (ans[pos] == 12) cout << 'Q'; else if (ans[pos] == 11) cout << 'J'; else if (ans[pos] == 10) cout << 10; else cout << ans[pos]; cout << ' '; } }
0.0分
29 人评分
数组输出 (C语言代码)错误???浏览:566 |
简单的a+b (C语言代码)浏览:693 |
printf基础练习2 (有点不明白)浏览:845 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:514 |
淘淘的名单 (C语言代码)浏览:1104 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:507 |
C语言程序设计教程(第三版)课后习题6.8 (C++代码)浏览:591 |
C语言程序设计教程(第三版)课后习题9.2 (C语言代码)浏览:556 |
用筛法求之N内的素数。 (C语言代码)浏览:531 |
GC的苦恼 (C语言代码)浏览:621 |