Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- struct coada
- {long c[3010];
- long inc,sf;
- };
- coada cd;
- void push(int x,coada & y)
- {y.sf++;
- y.c[y.sf]=x;
- }
- void pop(coada&y)
- {if(y.inc<=y.sf)
- y.inc++;
- }
- void front (coada y)
- {if(y.inc<=y.sf)
- cout<<y.c[y.inc]<<endl;
- }
- int main ()
- {cd.sf=-1;
- int n,nr;
- char s[7];
- cin>>n;
- for(int i=1;i<=n;i++)
- {cin>>s;
- if(strcmp(s,"push")==0)
- {cin>>nr;
- push(nr,cd);
- }
- else if(strcmp(s,"pop")==0)
- pop(cd);
- else if(strcmp(s,"front")==0)
- front(cd);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement