cl258 @ 2023-05-10 19:40:11
为什么陷入死循环,回车后还在等你输入,判断总和能过,但是为什么这个不行
#include<bits/stdc++.h>
using namespace std;
int s[40000];
int main()
{
int n, a, p = 0, i = 0;
cin>>n;
while(cin>>a){
if(p %2 == 0){
while(a--) s[i++] = 0;
}else {
while(a--) s[i++] = 1;
}
p++;
}
for(int j = 0 ; j < n*n ;j++) {
if (j % n == n - 1) cout << s[j] << endl;
else cout << s[j];
}
return 0;
}
by zhouzihang1 @ 2023-05-10 20:06:18
while (cin >> n)
需要 Ctrl + Z 来结束循环
by cl258 @ 2023-05-11 18:39:32
@zhouzihang1 牛逼
by VoId_D_C @ 2023-05-17 20:48:33
我用devc++Ctrl+什么都能停