6 solutions
-
2
#include<bits/stdc++.h> using namespace std; char q[246],a[8]; int front=0,rear=0; void push(char x) { if(rear<124) { q[rear]=x; rear++; } } void pop() { if(front!=rear) { front++; } } char getFront() { return q[front]; } int size() { return rear-front; } int main() { cin>>a; for(int i=0;i<strlen(a);i++) { push(a[i]); } int k=1; while(size()!=0) { if(k%2!=0) { cout<<getFront()<<" "; pop(); } else { push(getFront()); pop(); push(getFront()); pop(); } k++; } return 0; }
Information
- ID
- 2321
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 7
- Tags
- # Submissions
- 19
- Accepted
- 9
- Uploaded By