wzy20110830 @ 2024-02-20 16:12:05
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,x=0,k;
vector <int> a;
cin>>n;
int sq[(int)pow(n,2)]={0};
while(x<(int)pow(n,2))
{
cin>>k;
a.push_back(k);
x+=k;
}
for(int i=0;i<a.size();i++)
for(int j=0;j<a[i];j++)
{
if(i%2!=0) sq[i]=0;
else sq[i]=1;
}
for(int i=0;i<(int)pow(n,2);i++)
{
cout<<sq[i];
if((i+1)%n==0) cout<<endl;
}
return 0;
}
by Xia_Yu_Chen @ 2024-02-25 23:43:47
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,x=0,k;
vector <int> a;
cin>>n;
int sq[(int)pow(n,2)]={0};
while(x<(int)pow(n,2))
{
cin>>k;
a.push_back(k);
x+=k;
}
int sum = 0;
for(int i=0;i<a.size();i++){
for(int j=0;j<a[i];j++)
sq[sum + j] = i % 2;
sum += a[i];
}
//i是下标不是个数,开sum记录已经修改了多少个数了,记得加j不然修改的位置循环内不变
for(int i=0;i<(int)pow(n,2);i++)
{
cout<<sq[i];
if((i+1)%n==0) cout<<endl;
}
return 0;
}