Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1.     class Node
  2.     {
  3.         public int wartosc;
  4.         public Node next;
  5.     }
  6.  
  7.     class Kolejka
  8.     {
  9.         Node first, last;
  10.  
  11.         /* dodaje Nodeent na koniec kolejki */
  12.         public void add(int x)
  13.         {
  14.             Node temp = new Node;
  15.             temp.warosc =x;
  16.             if (first == null)
  17.             {
  18.                 first = last = temp;
  19.             }
  20.             else
  21.             {
  22.                 last.next = temp;
  23.                 last = temp;
  24.             }
  25.  
  26.         }
  27.  
  28.         /* sciaga z kolejki Nodeent na 1 miejscu */
  29.         public void delete()
  30.         {
  31.             if (first != null)
  32.             {
  33.                 if (first.next == null)
  34.                 {
  35.                     last = null;
  36.                 }
  37.  
  38.                 first = first.next;
  39.             }
  40.             else Console.WriteLine("kolejka jest pusta");
  41.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement