wangqianyi @ 2022-03-19 09:14:45
#include <iostream>
using namespace std;
const int maxn = 4e4+5;
int a[maxn];
int main()
{
int n;
cin>>n;
int x,s=0,pre=1,cnt=0;
while(1)
{
cin>>x;
s+=x;
cnt++;
for(int i=pre;i<=pre+x;i++)
{
if(cnt%2)
{
a[i]=0;
}
else
{
cout<<a[i];
}
}
pre+=x;
if(s==n*n)
{
break;
}
}
for(int i=1;i<=n*n;i++)
{
if(i%7==0)
{
cout<<a[i]<<endl;
}
else
{
cout<<a[i];
}
}
return 0;
}
by Lvyuze @ 2022-03-19 09:29:10
@wangqianyi 您的思路看不懂,说说我的思路。
一个二维数组存储输出的矩阵,一个变量存储 1 或 0,
最后输出
by wangqianyi @ 2022-03-19 09:40:10
@Lvyuze emm......
by Jasper08 @ 2022-03-19 10:44:10
@wangqianyi
#include <iostream>
using namespace std;
int main()
{
int n = 0;
cin >> n;
int num[40005] = {};
short sum = 0;
int i = 0;
while (sum != n * n)
{
cin >> num[i];
sum += num[i];
++i;
}
int count = 0, zo = 0;
for (int j = 0; j <= i; ++j)
{
for (int k = 0; k < num[j]; ++k)
{
++count;
if ((count - 1) % n == 0 && count - 1 != 0)
cout << endl;
cout << zo;
}
if (zo == 0)
zo = 1;
else
zo = 0;
}
return 0;
}