题解 | #01矩阵#
01矩阵
https://ac.nowcoder.com/acm/contest/120562/E
构造题,根据题意写几个,找出规律
00
01
000
011
010
0000
0111
0100
0101
00000
01111
01000
01011
01010
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int a[1005][1005];
for(int i=1;i<=n;i++){
if(i%2==0){
for(int j=i;j<=n;j++){
a[i][j]=1;
a[j][i]=1;
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++)
cout<<a[i][j];
cout<<endl;
}
}
using namespace std;
int main(){
int n;
cin>>n;
int a[1005][1005];
for(int i=1;i<=n;i++){
if(i%2==0){
for(int j=i;j<=n;j++){
a[i][j]=1;
a[j][i]=1;
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++)
cout<<a[i][j];
cout<<endl;
}
}

