fork download
  1. #include<iostream>
  2. #include<string>
  3. using namespace std;
  4. char znak;
  5. int tab[10], i = 0;
  6.  
  7. int push(int element)
  8. {
  9. tab[i++] = element;
  10. return 1;
  11. }
  12.  
  13. int pop()
  14. {
  15. --i;
  16. return 1;
  17. }
  18. int value()
  19. {
  20. return tab[i];
  21. }
  22.  
  23.  
  24. int main()
  25. {
  26. while (cin>>znak && (znak=='+' || '=') )
  27. {
  28. if (znak == '+')
  29. {
  30. int liczba;
  31. cin >> liczba;
  32. if (i >= 10) cout << ":(" << endl;
  33. else
  34. {
  35. push(liczba);
  36. cout << ":)" << endl;
  37. }
  38. }
  39. else if (znak == '-')
  40. {
  41. if (i == 0) cout << ":("<<endl;
  42. else
  43. {
  44. pop();
  45. cout << value() << endl;
  46. }
  47. }
  48.  
  49.  
  50. }
  51. return 0;
  52. }
Success #stdin #stdout 0s 15232KB
stdin
1 2 3 4 5 6 7 8 9 0 1
stdout
Standard output is empty