c++,求助,为啥全是wa啊,目前怀疑是读到数组d的问题

P1319 压缩技术

damuzhi @ 2023-10-14 16:42:30

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    cin >> n;
    int f = 0;
    int a[201];
    int i = 0;
    while(f < n * n){

        cin >> a[i];
        f += a[i];
        i++;
    }
    int fj = 0;
    int d[n * n];
    // int j = 0;
    for(int i = 0; i < n; i++){
        if(i % 2 == 0){
            for(int j = 0; j < a[i];j++){
                d[fj] = 0;
                fj++;
            }
        }
        if(i % 2 == 1){
            for(int j = 0; j < a[i];j++){
                d[fj] = 1;
                fj++;
            }
        }
    }
    int fjj = 0;
    for(int i = 0;i < n; i++){
        for(fjj = fjj;i < n; i++){
        cout << d[fjj];
    }
    cout << endl;
    }
    return 0;
}

|