Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace SZTOS
- {
- public class stos
- {
- public int [] dane;
- public int top;
- Random rnd = new Random();
- public void init(int rozmiar)
- {
- dane = new int[rozmiar];
- top = -1;
- }
- //dodanie
- public void push ()
- {
- dane[++top] = rnd.Next(1, 10);
- }
- //zrzucenie
- public int pop()
- {
- return dane[top--] = 0;
- }
- //odczytanie z gory
- public void topp()
- {
- Console.Write("\n");
- Console.Write(dane[top]);
- Console.Write("\n");
- }
- // sprawdzanie czy pusty
- public void empty()
- {
- if (top == 0)
- {
- Console.Write("\n");
- Console.Write("Stos jest pusty");
- Console.Write("\n");
- }
- else
- {
- Console.Write("\n");
- Console.Write("Stos nie jest pusty");
- Console.Write("\n");
- }
- }
- //sprawdzanie czy pelny
- public void full()
- {
- if (dane[top] != 0)
- {
- Console.Write("\n");
- Console.Write("Stos jest pełny");
- Console.Write("\n");
- }
- else
- {
- Console.Write("\n");
- Console.Write("Stos nie jest pełny");
- Console.Write("\n");
- }
- }
- public void destroy()
- {
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement