Advertisement
Guest User

Untitled

a guest
Mar 26th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. struct coada
  5. {long c[3010];
  6. long inc,sf;
  7. };
  8. coada cd;
  9. void push(int x,coada & y)
  10. {y.sf++;
  11. y.c[y.sf]=x;
  12. }
  13. void pop(coada&y)
  14. {if(y.inc<=y.sf)
  15. y.inc++;
  16. }
  17. void front (coada y)
  18. {if(y.inc<=y.sf)
  19. cout<<y.c[y.inc]<<endl;
  20. }
  21. int main ()
  22. {cd.sf=-1;
  23. int n,nr;
  24. char s[7];
  25. cin>>n;
  26. for(int i=1;i<=n;i++)
  27. {cin>>s;
  28. if(strcmp(s,"push")==0)
  29. {cin>>nr;
  30. push(nr,cd);
  31. }
  32. else if(strcmp(s,"pop")==0)
  33. pop(cd);
  34. else if(strcmp(s,"front")==0)
  35. front(cd);
  36. }
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement