hhhqhhh @ 2024-10-16 23:38:54
#include<iostream>
using namespace std;
int main()
{
long long n,s[10000],k=1,i,j,m=0,a,b;
cin>>n;
for(i=1;i<10000;i++)
{
cin>>s[i];
if(getchar()=='\n')
{
k=i;
break;
}
}
for(i=1;i<=k;i++)
{
a=s[i];
for(j=1;j<=a;j++)
{
if((i%2)==0)
b=1;
else
b=0;
cout<<b;
m++;
if(m%n==0&&m!=n*n)
{
cout<<endl;
}
}
}
return 0;
}
by __Monody__ @ 2024-11-17 11:29:23
嗯...看不出来哪里错了可以看看我的代码
#include <stdio.h>
int main() {
int n;
scanf("%d", &n);
int a;
int flag = 0;
int cnt = 0;
int sum = 0;
while (sum < n * n) {
scanf("%d", &a);
sum += a;
for (int i = 0; i < a; ++i) {
if (flag == 0) {
printf("0");
cnt++;
if (cnt % n == 0) {
printf("\n");
}
} else {
printf("1");
cnt++;
if (cnt % n == 0) {
printf("\n");
}
}
}
if (flag == 0) {
flag = 1;
} else {
flag = 0;
}
}
return 0;
}
AC的代码 求互关