#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
void Init(string A[100]);
void Change(int B[100], int n, string A[100]);
int main()
{
string A[100];
int B[100];
Init(A);
int n;
cin >> n;
for (int i = 1; i <= 54; i++)
cin >> B[i];
Change(B, n, A);
for (int i = 1; i <= 54; i++)
{
if (i == 54)
cout << A[i] << endl;
else
cout << A[i] << ' ';
}
system("pause");
return 0;
}
void Change(int B[100], int n, string A[100])
{
int t = 0;
while (t < n)
{
int pos = 1;
int nextpos = B[pos];
string posstr = A[pos];
string nextposstr = A[nextpos];
bool flag = true;
int visited[100] = { 0 };
while(flag)
{
nextposstr = A[nextpos];
A[nextpos] = posstr;
visited[nextpos] = 1;
posstr = nextposstr;
pos = nextpos;
nextpos = B[nextpos];
if (visited[nextpos] != 0)
{
bool f = false;
for (int i = 1; i <= 54; i++)
{
if (visited[i] == 0)
{
pos = i;
nextpos = B[pos];
posstr = A[pos];
nextposstr = A[nextpos];
f = true;
break;
}
}
if (!f)
flag = false;
}
}
t++;
}
}
void Init(string A[100])
{
int t = 1;
for (int i = 1; i <= 4; i++)
{
for (int j = 1; j <= 13; j++)
{
switch (i)
{
case 1: A[t] = "S"; break;
case 2: A[t] = "H"; break;
case 3: A[t] = "C"; break;
case 4: A[t] = "D"; break;
}
A[t++] += to_string(j);
}
}
A[t++] = "J1";
A[t++] = "J2";
t--;
}
1042
猜你喜欢
转载自blog.csdn.net/zero_1778393206/article/details/87933377
今日推荐
周排行