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.

30 lines
1.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
int n; //汉字点阵的长和宽
int nums; //输出1还是0呢默认是0
int m; //每次输入的值是几个
int K; //已经处理完的数字个数
int main() {
cin >> n;//几行几列本题示例是7
/*(1)数据的读入需要有终止的条件。因为我们不知道具体要输入多少个压缩码,
所以不好用for循环或while循环读入指定次数。还有一个可以利用的终止条件
就是因为这是一个二维的矩阵所以肯定是n*n个数字为上限只要保证k<n*n就一直需要读入数据。
(2)k是一次性增长1个每一轮增长m个的
*/
while (k < n * n) {
cin >> m;
for (int j = 1; j <= m; j++) {
printf("%d", num);
//数量,用于判断是否换行,另一个重要的作用是用来判断程序是否该结束了
k++;
//换行
if (k % n == 0) printf("\n");
}
//调整为相反数,为下一次做准备
num = !num;
}
return 0;
}