PAT1042题解

#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#include<cstring>
#include<stdio.h>
#include<queue>
using namespace std;
struct str{
	char ch[4];
};
vector<str>vec;
vector<str>res;
int order[100];
void G(char s,int len) {
	
	for(int i = 1; i <= len; i++) {
		str temp;
		temp.ch[0] = s;
		sprintf(temp.ch+1,"%d",i);
		vec.push_back(temp);
	}
}
int main() {
	vec.push_back(str());
	G('S',13);
	G('H',13);
	G('C',13);
	G('D',13);
	G('J',2);
	int num;
	cin >> num;
	for(int i = 1; i <= 54; i++) {
		cin >> order[i];
	}
	res.resize(100);
	while(num--) {
		for(int i = 1; i <= 54; i++) {
			res[order[i]] = vec[i];
		}
		vec.clear();
		vec.assign(res.begin(), res.end());
	}
	for(int i = 1; i <=54; i++) {
		if(i != 54) {
			cout << res[i].ch << " ";
		}else {
			cout << res[i].ch;
		}
	}
	
}

  注意一下 vector之间的复制 将数组作为 vector存储元素的方法。

转载于:https://www.cnblogs.com/dcklm/p/10350235.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值