Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Fronta
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Hello World!");
- fronta frontal = new fronta(15);
- Console.WriteLine(frontal.isempty());
- frontal.enqueue(50);
- frontal.peek();
- frontal.enqueue(15);
- frontal.dequeue();
- frontal.peek();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Fronta
- {
- class fronta
- {
- private int[] fronticka = new int[0];
- private bool prazdnota;
- private int index = 0;
- private int start = 0;
- public fronta(int n)
- {
- fronticka = new int[n];
- }
- public bool isempty()
- {
- prazdnota = true;
- if (index == start)
- {
- prazdnota = false;
- }
- return prazdnota;
- }
- public void enqueue(int prvek)
- {
- fronticka[index] = prvek;
- index++;
- }
- public void peek()
- {
- Console.WriteLine(fronticka[index - 1]);
- }
- public void dequeue()
- {
- fronticka[start] = 0;
- start++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment