Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///coada alocata static
- #include <bits/stdc++.h>
- #define N 10001
- using namespace std;
- struct Coada
- {
- int q[N];
- int pr,ul;
- void Init(){pr=0; ul=-1;}
- int Empty(){return pr>ul;}
- void Push(int x){q[++ul]=x;}
- void Pop(){if(!Empty()) pr++;}
- int Front(){return q[pr];}
- };
- int main()
- {
- int n,x;
- Coada a;
- char s[7];
- a.Init();
- cin>>n;
- for(int i=1;i<=n;i++)
- {
- cin>>s;
- if(strcmp(s,"push")==0) {cin>>x;a.Push(x);}
- else if(strcmp(s,"pop")==0) a.Pop();
- else
- {
- if(!a.Empty())cout<<a.Front()<<"\n";
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement