summer_flower @ 2023-05-06 21:26:56
#include<stdio.h>
#include<string.h>
int main(){
int n;
scanf("%d",&n);
int a[200000],b[200000];
int i,j=0,k,c=0;
char s;
for(i=0;i<201&&s!='\n';i++){
scanf("%d",&b[i]);
s=getchar();
c++;
}
int p=c;
for(i=0;i<p;i++){
if(i%2==0){
for(k=0;k<b[i];k++){
a[j]=0;
j++;
}
}
else{
for(k=0;k<b[i];k++){
a[j]=1;
j++;
}
}
}
for(i=0;i<n*n;i++){
if(i%n==0)
printf("\n");
printf("%d",a[i]);
}
return 0;
}
by zhouzihe @ 2023-05-06 21:40:29
#include<bits/stdc++.h>
using namespace std;
long long int n,a[10001],m=1,sumn=0;
int main(){
cin>>n;
while(cin>>a[m]){
m++;
}
for(int i=1;i<m;i++){
for(int j=1;j<=a[i];j++){
if(i%2==1){
cout<<"0";
}
if(i%2==0){
cout<<"1";
}
sumn++;
if(sumn==n){
cout<<endl;
sumn=0;
}
}
}
}
请关注me,蟹蟹
by keven_wang @ 2023-05-11 18:24:59
你用数组存不好判断终点。
by summer_flower @ 2023-05-13 13:17:08
@keven_wang 但是一边输入一边判断会超时