1042 Shuffling Machine (20)(20 分)

#include
#include
#include
using namespace std;
const int maxn = 1e3 + 10;
int num[maxn], temp[maxn],shuff[maxn], k;
void show(int n)
{
	if (n <= 13)printf("S%d", n);
	else if (n <= 26)printf("H%d", n - 13);
	else if (n <= 39)printf("C%d", n - 26);
	else if (n <= 52)printf("D%d", n - 39);
	else printf("J%d", n - 52);
}
int main()
{
	for (int i = 1; i <= 54; i++)num[i] = i;
	scanf("%d", &k);
	for (int i = 1; i <= 54; i++)scanf("%d", &shuff[i]);
	while (k--)
	{
		for (int i = 1; i <= 54; i++)
		{
			temp[shuff[i]] = num[i];
		}
		for (int i = 1; i <= 54; i++)num[i] = temp[i];
	}
	for (int i = 1; i <= 54; i++)
	{
		show(num[i]);
		if (i != 54)printf(" ");
	}
	return 0;
}

 

你可能感兴趣的:(PAT甲级真题)