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