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