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:21:56
@change_fate 要改成我这样
by yzm0325 @ 2023-01-27 14:28:53
@Offending_username 拿到10分,代码:
#include <iostream>
#include <cstring>
using namespace std;
int a[40010], n, zt, iindex, m;
int main() {
cin >> n;
memset(a, 0, sizeof(a));
while(1) {
cin >> m;
for(int i = 1; i <= m; i++) a[i] = zt;
zt = !zt, iindex += m;
if(iindex = n * n) break;
}
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= n; j++) cout << a[j + (i - 1) * n];
cout << endl;
}
return 0;
}
记录
by Offending_user_name_ @ 2023-01-27 14:31:14
@Zhuyiming0325 zt=!zt
有风险,有可能会给你蹦出来一个奇奇怪怪的非0数
by yzm0325 @ 2023-01-27 14:33:47
没有吧
by yzm0325 @ 2023-01-27 14:35:33
@Offending_username 是的不会
by Offending_user_name_ @ 2023-01-27 14:36:55
@Zhuyiming0325 第12行和10行有问题,其实都是小问题。
by Offending_user_name_ @ 2023-01-27 14:37:51
我AC了(关注我送AC代码)
by Offending_user_name_ @ 2023-01-27 14:38:00
by yzm0325 @ 2023-01-27 14:40:30
你刚AC的 @Offending_username
by Offending_user_name_ @ 2023-01-27 14:41:31
@Zhuyiming0325 没错,在你原来的代码上改了4处错误就对了。