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存储元素的方法。

猜你喜欢

转载自www.cnblogs.com/dcklm/p/10350235.html