奇异做法
2026-07-30 21:12:05
发布于:江苏
1阅读
0回复
0点赞
只需记录0的数量,原样输出除0的数,再输出0,就行了,但要用2个循环:
#include<iostream>
using namespace std;
int main(){
int n, a;
cin >> n;
int cnt = 0;
while(n--){
cin >> a;
if(a == 0) cnt++;
else cout << a << ' ';
}
while(cnt--) cout << 0 << ' ';
return 0;
}
这里空空如也







有帮助,赞一个