fork(4) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. string sign;
  5. int tab[11];
  6. int y=0,number;
  7.  
  8. void push()
  9. {
  10. cin>>number;
  11.  
  12. if (y>=10)
  13. {
  14. cout<<":("<<endl;
  15. }
  16. else
  17. {
  18. y++;
  19. tab[y]=number;
  20. cout<<":)"<<endl;
  21. }
  22. }
  23.  
  24. void pop()
  25. {
  26. if(y==0)
  27. {
  28. cout<<":("<<endl;
  29. }
  30. else
  31. {
  32. cout<<tab[y]<<endl;
  33. y--;
  34. }
  35.  
  36. }
  37.  
  38.  
  39. int main()
  40. {
  41. while(!cin.eof())
  42. {
  43. cin>>sign;
  44. if(sign=="+" || sign=="-")
  45. {
  46. if ( sign=="+")
  47. {
  48. push();
  49. }
  50. else if (sign=="-")
  51. {
  52. pop();
  53. }
  54.  
  55. }
  56. }
  57.  
  58. return 0;
  59. }
  60.  
  61.  
Success #stdin #stdout 0s 4504KB
stdin
+
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
0
+
1
-
-
-
-
-
-
-
-
-
-
-
stdout
:)
:)
:)
:)
:)
:)
:)
:)
:)
:)
:(
0
9
8
7
6
5
4
3
2
1
:(