Files
python/TangDou/LuoGuBook/P1319.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

30 lines
1.1 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}