You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
2.3 KiB

#include<bits/stdc++.h>
using namespace std;
//思路:打表找规律,也是思考问题的重要方法,一题两解,是一道简单直白的试题
int main() {
int n;
cin >> n;
cout << n << endl;//据打表的n有n次
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
if ((i % 2 == 1 && j <= i) || (i % 2 == 0 && j > i))
cout << "0";
else
cout << "1";
}
cout << endl;
}//据打表的
return 0;
}
/*
2
01
11
--------------------
4
0111
1100
0001
1111
--------------------
6
011111
110000
000111
111100
000001
111111
--------------------
8
01111111
11000000
00011111
11110000
00000111
11111100
00000001
11111111
--------------------
10
0111111111
1100000000
0001111111
1111000000
0000011111
1111110000
0000000111
1111111100
0000000001
1111111111
--------------------
12
011111111111
110000000000
000111111111
111100000000
000001111111
111111000000
000000011111
111111110000
000000000111
111111111100
000000000001
111111111111
--------------------
14
01111111111111
11000000000000
00011111111111
11110000000000
00000111111111
11111100000000
00000001111111
11111111000000
00000000011111
11111111110000
00000000000111
11111111111100
00000000000001
11111111111111
--------------------
16
0111111111111111
1100000000000000
0001111111111111
1111000000000000
0000011111111111
1111110000000000
0000000111111111
1111111100000000
0000000001111111
1111111111000000
0000000000011111
1111111111110000
0000000000000111
1111111111111100
0000000000000001
1111111111111111
--------------------
18
011111111111111111
110000000000000000
000111111111111111
111100000000000000
000001111111111111
111111000000000000
000000011111111111
111111110000000000
000000000111111111
111111111100000000
000000000001111111
111111111111000000
000000000000011111
111111111111110000
000000000000000111
111111111111111100
000000000000000001
111111111111111111
--------------------
20
01111111111111111111
11000000000000000000
00011111111111111111
11110000000000000000
00000111111111111111
11111100000000000000
00000001111111111111
11111111000000000000
00000000011111111111
11111111110000000000
00000000000111111111
11111111111100000000
00000000000001111111
11111111111111000000
00000000000000011111
11111111111111110000
00000000000000000111
11111111111111111100
00000000000000000001
11111111111111111111
*/