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