fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. class Stos
  8. {
  9. public int[] tablica = new int[10];
  10. int s_top=0;
  11.  
  12.  
  13. public void push()
  14. {
  15. if (s_top == 10)
  16. Console.WriteLine(":(");
  17. else
  18. {
  19.  
  20. tablica[s_top] = int.Parse(Console.ReadLine());
  21. s_top ++;
  22. Console.WriteLine(":)");
  23. }
  24. }
  25. public void pop()
  26. {
  27. if (s_top == 0)
  28. Console.WriteLine(":(");
  29. else
  30. {
  31. Console.WriteLine(tablica[s_top-1]);
  32. s_top --;
  33. }
  34.  
  35. }
  36. }
  37.  
  38.  
  39.  
  40. class Program
  41. {
  42.  
  43. static void Main(string[] args)
  44. {
  45. Stos stos_1 = new Stos();
  46. while (true)
  47. {
  48.  
  49.  
  50. string a = Console.ReadLine();
  51. if (a[0] == '+')
  52. stos_1.push();
  53. else if(a[0]=='-')
  54. stos_1.pop();
  55.  
  56. }
  57.  
  58. }
  59.  
  60. }
  61.  
  62.  
  63.  
  64.  
Runtime error #stdin #stdout #stderr 0.01s 134976KB
stdin
+
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
0
+
1
-
-
-
-
-
-
-
-
-
-
-
stdout
:)
:)
:)
:)
:)
:)
:)
:)
:)
:)
:(
0
9
8
7
6
5
4
3
2
1
:(
stderr
Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object
  at Program.Main (System.String[] args) [0x0000c] in <e1d69ec8c8814cb580f766201b17920c>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object
  at Program.Main (System.String[] args) [0x0000c] in <e1d69ec8c8814cb580f766201b17920c>:0