2 solutions
-
1
#include<bits/stdc++.h> using namespace std; queue<int>q; vector<int>c; int main() { int n; cin>>n; for(int i=0;i<n;i++) { int a; cin>>a; q.push(a); } int x=0; while(!q.empty()) { x++; if(x%2==1) { cout<<q.front()<<" "; q.pop(); } else if(x%2==0) { q.push(q.front()); q.pop(); } } return 0; } -
0
#include<bits/stdc++.h> using namespace std; int q[105],f,r; void ps(int x){ q[r]=x; r++; } void pp(){ f++; } int gf(){ return q[f]; } int sz(){ return r-f; } int main(){ int n,x; cin>>n; f=0;r=0; for(int i=1;i<=n;i++){ cin>>x; ps(x); } int k=1; while(sz()!=0){ if(k%2==1){ cout<<gf()<<" "; pp(); }else{ ps(gf()); pp(); } k++; } return 0; }
- 1
Information
- ID
- 1869
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 33
- Accepted
- 15
- Uploaded By