HzuWHF


私信TA

用户名:I7I08I9047

访问量:77397

签 名:

我RUN了

等  级
排  名 18
经  验 20560
参赛次数 13
文章发表 127
年  龄 3
在职情况 学生
学  校 贺州学院
专  业

  自我简介:



参考代码:

#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 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区