dream_contry @ 2023-10-04 20:20:13
放编译器上没问题,到洛谷上CE了
#include<bits/stdc++.h>
using namespace std;
int n;
int a[1000005];
int main(){
cin>>n;
int z=n*n,x=0,t=0;
while((cin>>a[x])!=0){
x++;
}
for(int i=0;i<x;i++){
if(i%2==0){
for(int j=1;j<=a[i];j++){
t++;
if(t>n){
cout<<endl;
t=1;
}
cout<<0;
}
}
else{
for(int j=1;j<=a[i];j++){
t++;
if(t>n){
cout<<endl;
t=1;
}
cout<<1;
}
}
}
return 0;
}
by MTF_Lambda_04 @ 2023-10-04 20:28:49
while你那里不要那么写吧
by sugawara @ 2023-10-04 20:29:43
把你while循环的条件改一下就行了,改成下面的
code:
while(true){
cin>>a[x];
if(a[x]==0) break;
x++;
}
but你的算法有点问题,只有20
by MTF_Lambda_04 @ 2023-10-04 20:29:46
while那里改下,多半是while的问题
by dream_contry @ 2023-10-04 20:31:43
蟹蟹各位大佬(第一次被红题整吐了)
by dream_contry @ 2023-10-04 20:34:18
@only_one
#include<bits/stdc++.h>
using namespace std;
int n;
int a[1000005];
int main(){
cin>>n;
int z=n*n,x=0,t=0;
while(true){
cin>>a[x];
if(a[x]==0 && x!=0) break;
x++;
}
for(int i=0;i<x;i++){
if(i%2==0){
for(int j=1;j<=a[i];j++){
t++;
if(t>n){
cout<<endl;
t=1;
}
cout<<0;
}
}
else{
for(int j=1;j<=a[i];j++){
t++;
if(t>n){
cout<<endl;
t=1;
}
cout<<1;
}
}
}
return 0;
}
这是满昏哒