Fandis @ 2024-10-18 15:12:51
#include<bits/stdc++.h>
using namespace std;
int a[40005],b[25][25];
int main(){
int n,k,m,p,x=1;
cin>>n;
k=n*n;
while(k>0)
{
cin>>m;
while(m>0)
{
a[x]=0;
m--;
k--;
x++;
}
cin>>p;
while(p>0)
{
a[x]=1;
p--;
k--;
x++;
}
}
int r=1;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
{
b[i][j]=a[r];
r++;
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cout<<b[i][j];
}
cout<<endl;
}
return 0;
}
by hans108 @ 2024-11-04 12:12:19
b数组开小了,改后已AC:
#include<bits/stdc++.h>
using namespace std;
int a[40005],b[205][205];
int main(){
int n,k,m,p,x=1;
cin>>n;
k=n*n;
while(k>0)
{
cin>>m;
while(m>0)
{
a[x]=0;
m--;
k--;
x++;
}
cin>>p;
while(p>0)
{
a[x]=1;
p--;
k--;
x++;
}
}
int r=1;
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
{
b[i][j]=a[r];
r++;
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cout<<b[i][j];
}
cout<<endl;
}
return 0;
}
求关注
@Fandis
by Fandis @ 2024-11-04 21:12:17
@hans108 好的谢谢❤❤