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

:)

:)

:)

:)

:)

:)

:)

:)

:)

:(
0987654321
:(