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 Kolos_Algorytmy_v2
- {
- class Queue
- {
- int?[] array;
- int head = 0, tail = 0, size = 0;
- public Queue(int size)
- {
- array = new int?[size];
- }
- public void Enque(int number)
- {
- if (size != array.Length)
- {
- size++;
- array[tail++] = number;
- tail = tail % array.Length;
- }
- }
- public int? Deque()
- {
- int? back= null;
- if (size != 0)
- {
- back = array[head];
- array[head] = null;
- size--;
- head = (head + 1) % array.Length;
- }
- return back;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement