自己思路,没通过

#include <cstdio>
#define N  54
int main() {
    #ifdef ONLINE_JUDGE
    #else
        freopen("1.txt", "r", stdin);
    #endif
    int start[N + 1] = {0}, end[N + 1] = {0}, sequence[N + 1] = {0};
    for(int i = 1; i < N + 1; i++) {//初始化牌的编号
        start[i] = i+1;
    }
    int n;
    scanf("%d", &n);//输入操作的次数
    for(int i = 1; i < N + 1; i++) {//输入每个位置上的牌在操作后的位置
        int n;
        scanf("%d", &sequence[i]);
    }
    /*for(int i = 1; i < N; i++) {
        printf("%dn", sequence[i]);
    }*/
    for(int i = 0; i < n; i++) {//执行n次操作
        for(int i = 1; i < N + 1; i++) {
            end[sequence[i]] = start[i];
        }
        for(int i = 1; i < N + 1; i++) {
            start[i] = end[i];
        }
    }
    /*for(int i = 1; i < N + 1; i++) {
        printf("%dn", end[i]);
    }
    */
    for(int i = 1; i < N; i++) {
        //printf("%d---", end[i]);
        if(i != N) {
            if(end[i] / 13 == 0) {
                if(end[i] % 13 == 0) {
                    printf("S13 ");
                } else {
                    printf("S%d ", end[i] % 13);
                }
            } else if(end[i] / 13 == 1) {
                if(end[i] % 13 == 0) {
                    printf("H13 ");
                } else {
                printf("H%d ", end[i] % 13);
                }
            } else if(end[i] / 13 == 2) {
                if(end[i] % 13 == 0) {
                    printf("C13 ");
                } else {
                    printf("C%d ", end[i] % 13);
                }
            } else if(end[i] / 13 == 3) {
                if(end[i] % 13 == 0) {
                    printf("D13 ");
                } else {
                    printf("D%d ", end[i] % 13);
                }
            } else if(end[i] / 13 == 4) {
                printf("J%d ", end[i] % 13);
            }
        } else {
            if(end[i] / 13 == 0) {
                if(end[i] % 13 == 0) {
                    printf("S13");
                } else {
                    printf("S%d", end[i] % 13);
                }
            } else if(end[i] / 13 == 1) {
                if(end[i] % 13 == 0) {
                    printf("H13");
                } else {
                printf("H%d", end[i] % 13);
                }
            } else if(end[i] / 13 == 2) {
                if(end[i] % 13 == 0) {
                    printf("C13");
                } else {
                    printf("C%d", end[i] % 13);
                }
            } else if(end[i] / 13 == 3) {
                if(end[i] % 13 == 0) {
                    printf("D13");
                } else {
                    printf("D%d", end[i] % 13);
                }
            } else if(end[i] / 13 == 4) {
                printf("J%d", end[i] % 13);
            }
        }
    }
    return 0;
}

AC

#include <cstdio>
const int N = 54;
char mp[5] = {'S', 'H', 'C', 'D', 'J'};
int start[N+1], end[N+1], next[N+1];

int main() {
    #ifdef ONLINE_JUDGE
    #else
        freopen("1.txt", "r", stdin);
    #endif
    int K;
    scanf("%d", &K);
    for(int i = 1; i <= N; i++) {
        start[i] = i;
    }
    for(int i = 1; i <= N; i++) {
        scanf("%d", &next[i]);
    }
    for(int step = 0; step < K; step++) {
        for(int i = 1; i <= N; i++) {
            end[next[i]] = start[i];
        }
        for(int i = 1; i <= N; i++) {
            start[i] = end[i];
        }
    }
    for(int i = 1; i <= N; i++) {
        if(i != 1) printf(" ");
        start[i]--;
        printf("%c%d", mp[start[i] / 13], start[i] % 13 + 2);
    }
    return 0;
}
内容来源于网络如有侵权请私信删除
你还没有登录,请先登录注册
  • 还没有人评论,欢迎说说您的想法!