yzm0325 @ 2023-01-27 14:06:50
#include <iostream>
#include <cstring>
using namespace std;
int a[40010], n, zt = 0, iindex = 0, m;
int main() {
cin >> n;
memset(a, 0, sizeof(a));
for(; ; ) {
cin >> m;
for(int i = 1; i <= m; i++) a[i] = zt;
zt = !zt, iindex += m;
if(iindex = n * n) break;
}
int j = 1;
for(int i = 1; i <= n; i++) {
for(; j <= n; j++) cout << a << " ";
cout << endl;
}
return 0;
}
0分求助
by Offending_user_name_ @ 2023-01-27 14:10:05
这里给个小建议for(;;)
直接写成while(true)
就行了,for(;;)
不好看
by Offending_user_name_ @ 2023-01-27 14:12:16
变量定义在main外面是不需要些=0
的,除非你要强调什么
by yzm0325 @ 2023-01-27 14:12:40
@Offending_username 说得对,可以再简化成while(1)
by yzm0325 @ 2023-01-27 14:13:14
等于不等于的没关系吧?
by yzm0325 @ 2023-01-27 14:15:10
壮观的爆零
by Offending_user_name_ @ 2023-01-27 14:16:06
16行
by yzm0325 @ 2023-01-27 14:17:05
???
by yzm0325 @ 2023-01-27 14:18:20
@Offending_username 直接@我
by change_fate @ 2023-01-27 14:20:45
@Zhuyiming0325
cout << a << " ";
cout << a[j] << " ";
by Offending_user_name_ @ 2023-01-27 14:21:29
@Zhuyiming0325 输出要改成这个(复制到洛谷上就成这样了,凑合着看吧)
int j=1;
for(int i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
cout<<a[j+(i-1)*n]<<" ";
cout<<endl;
}