eolymp
bolt
Try our new interface for solving problems
Problems

Move zeroes

published at 1/2/24, 8:16:42 pm

include<bits/stdc++.h>

using namespace std; int main(){ int n,m; cin>>n; m=n; int a[n],i; for(i=0; i<n; i++) cin>>a[i]; for(i=0; i<n; i++){ if(i>=m) cout<<"0 "; else{ if(a[i]!=0) cout<<a[i]<<" "; else n++;} } }