大佬们!!!哪错了???搞了2个小时,还是错的!!!崩溃了!!!求求大佬们

P1319 压缩技术

Adore_love @ 2024-09-07 20:20:12

#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    int s=1;
    for(int i=1;i<=n;i++){
        int a;
        scanf("%d",&a);
        for(int j=1;j<=a;j++,s++){
            printf("%d",j%2==0);
            s++;
            if(s%n==0 && i!=n-1) printf("\n");
        }
    }
    return 0;
}

by EmptyAlien @ 2024-09-07 20:26:17

你没输出总数


by __F__ @ 2024-09-07 20:27:17

输入错了


by __LePetitPrince__ @ 2024-09-07 20:27:30

@yyda5203000b 错了很多处,给你盖好了


#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    int s=0,sum=0;
    for(int i=1;sum<n*n;i++){
        int a;
        scanf("%d",&a); sum+=a;
        for(int j=1;j<=a;j++){
            printf("%d",i%2==0);
            s++;
            if(s%n==0) printf("\n");
        }
    }
    return 0;
}```

by Adore_love @ 2024-09-07 20:31:53

@EmptyAlien @F @LePetitPrince 谢谢大佬!!!


|