PAT 1042(C++)

#include<iostream>
#include<map>
using namespace std;
map<int, int>cTop;//card to position
map<int, int>pToc;//position to card
int sh[54];
void shuffle(int times) {
	for (int i = 1; i <= 54; i++) cin >> sh[i - 1];
	while (times != 0) {
		for (int i = 1; i <= 54; i++) {
			int card = pToc[i];
			int temp = sh[i - 1];
			cTop[card] = temp;
		}
		for (auto it : cTop)
			pToc[it.second] = it.first;
		times--;
	}
}
int main() {
	for (int i = 1; i <= 54; i++) {
		cTop[i] = i; pToc[i] = i;
	}
	int times; cin >> times; 
	shuffle(times); map<int, int>::iterator ii = pToc.end();
	int count = 0;
	for (auto it : pToc) {
		int card = it.second; char put;
		if (card >= 1 && card <= 13) put = 'S';
		else if (card >= 14 && card <= 26) put = 'H';
		else if (card >= 27 && card <= 39) put = 'C';
		else if (card >= 40 && card <= 52) put = 'D';
		else put = 'J';
		cout << put << ((card % 13==0)?13:(card%13));
		count++;
		if (count!=54) cout << " ";
	}
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值