Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace SZTOS
  8. {
  9. public class stos
  10. {
  11. public int [] dane;
  12. public int top;
  13. Random rnd = new Random();
  14.  
  15. public void init(int rozmiar)
  16. {
  17. dane = new int[rozmiar];
  18. top = -1;
  19. }
  20. //dodanie
  21. public void push ()
  22. {
  23. dane[++top] = rnd.Next(1, 10);
  24. }
  25. //zrzucenie
  26. public int pop()
  27. {
  28. return dane[top--] = 0;
  29. }
  30. //odczytanie z gory
  31. public void topp()
  32. {
  33. Console.Write("\n");
  34. Console.Write(dane[top]);
  35. Console.Write("\n");
  36. }
  37. // sprawdzanie czy pusty
  38. public void empty()
  39. {
  40. if (top == 0)
  41. {
  42.  
  43. Console.Write("\n");
  44. Console.Write("Stos jest pusty");
  45. Console.Write("\n");
  46. }
  47. else
  48. {
  49. Console.Write("\n");
  50. Console.Write("Stos nie jest pusty");
  51. Console.Write("\n");
  52. }
  53. }
  54. //sprawdzanie czy pelny
  55.  
  56. public void full()
  57. {
  58. if (dane[top] != 0)
  59. {
  60. Console.Write("\n");
  61. Console.Write("Stos jest pełny");
  62. Console.Write("\n");
  63. }
  64. else
  65. {
  66. Console.Write("\n");
  67. Console.Write("Stos nie jest pełny");
  68. Console.Write("\n");
  69. }
  70. }
  71.  
  72. public void destroy()
  73. {
  74.  
  75.  
  76. }
  77.  
  78.  
  79.  
  80. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement