求助

P4387 【深基15.习9】验证栈序列

Dreamland_ @ 2024-12-02 23:02:07

0分为啥啊

#include<stdio.h>
int main() {
    int q;
    scanf("%d", &q);
    for(int c=0;c<q;c++){
    long long n;
    scanf("%lld", &n);
    long long a[100000] = { -1 };
    for (int i = 0; i < n; i++) {
        scanf("%llld", &a[i]);
    }
    long long b[100000] = { -1 };
    for (int j = 0; j < n; j++) {
        scanf("%lld", &b[j]);
    }
    long long* p1 = a;
    long long* p2 = b;
    p2 = p2 + n-1;
    int s;
    for (int z = 0; z < n; z++) {
        if (*p1 != *p2) {
            s = 1;
            printf("NO\n");
            break;
        }
        else {
            s = 0;
        }
        p1 = p1 + 1;
        p2 = p2 - 1;
    }
    if (s == 0) {
        printf("YES\n");
    }
    }
    return 0;
}

by yue2012 @ 2024-12-20 20:55:27

没大看懂...不过你有一个非常致命的错误就是你没仔细审题,是"Yes"不是"YES" @Dreamland_


|