Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace datova_struktura
- {
- class Program
- {
- static void Main(string[] args)
- {
- myStack zasobnicek = new myStack (5);
- Console.WriteLine(zasobnicek.isEmpty());
- zasobnicek.nefunguje();
- zasobnicek.Push(5);
- zasobnicek.nefunguje();
- zasobnicek.Push(6);
- zasobnicek.Push(85);
- zasobnicek.Push(52);
- zasobnicek.Push(25);
- zasobnicek.Peek();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace datova_struktura
- {
- class myStack
- {
- private int[] zasobak = new int[0];
- private bool prazdnota;
- private int index = 0;
- public myStack (int n)
- {
- zasobak = new int[n];
- }
- public bool isEmpty()
- {
- prazdnota = true;
- if (index != 0)
- {
- prazdnota = false;
- }
- return prazdnota;
- }
- public void Push(int prvek)
- {
- {
- zasobak[index] = prvek;
- index++;
- }
- }
- public void Peek ()
- {
- Console.WriteLine(zasobak[index-1]);
- }
- public void Pop()
- {
- zasobak[index-1] = 0;
- }
- public void nefunguje()
- {
- Console.WriteLine(zasobak[0]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment