其他分享
首页 > 其他分享> > PAT甲级1042

PAT甲级1042

作者:互联网

solution

#include <iostream>
#include <algorithm>
using namespace std;
const int N = 55, M = 1000010;
int a[N], b[M], c[N];
void solve(int x, int y)
{
    swap(a[x], a[y]);
}
int main()
{
    for (int i = 1; i < N; i++)
        a[i] = i;
    int n;
    cin >> n;
    int x;
    int idx = 1;
    for (int i = 1; i < N; i++)
    {
        cin >> x;
        b[idx] = x;
        idx++;
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 1; j < N; j++)
        {
            c[j] = a[j];
        }
        for (int k = 1; k < N; k++)
        {
            a[b[k]] = c[k];
        }
    }
    for (int i = 1; i < N; i++)
    {
        if (i != 1)
            cout << " ";
        int x = a[i];
        x -= 1;
        int t = x / 13;
        if (t == 0)
            cout << "S";
        else if (t == 1)
            cout << "H";
        else if (t == 2)
            cout << "C";
        else if (t == 3)
            cout << "D";
        else if (t == 4)
            cout << "J";
        cout << (x) % 13 + 1;
    }
}

标签:std,1042,PAT,idx,int,cin,++,甲级,include
来源: https://blog.csdn.net/qq_34832548/article/details/120178529