fork(1) download
  1. using System;
  2. using System.Collections;
  3.  
  4. public class MyFIFO
  5. {
  6. private Queue myQ;
  7.  
  8. public MyFIFO() {
  9. myQ = new Queue();
  10. }
  11. public void Add(int x) {
  12. myQ.Enqueue(x);
  13. }
  14.  
  15. public void Show() {
  16. foreach ( int x in myQ )
  17. Console.Write( " {0}\n", x );
  18. Console.WriteLine();
  19. }
  20.  
  21. public void Del() {
  22. myQ.Clear();
  23. }
  24. }
  25.  
  26. public class Test
  27. {
  28.  
  29. public static void Main()
  30. {
  31. MyFIFO Q1 = new MyFIFO(); //Объявили переменную типа нашей очереди FIFO (имя структуры)
  32. //Q1.Head=NULL; //Обозначили что голова пустая, ибо очередь пуста (можно в конструкторе)
  33. Q1.Add(100); //Добавляем элементы
  34. Q1.Add(200);
  35. Q1.Add(300);
  36.  
  37. Q1.Show(); //Показываем нашу очередь
  38. Q1.Del(); //Очищаем память
  39. }
  40. }
Success #stdin #stdout 0.04s 23920KB
stdin
Standard input is empty
stdout
    100
    200
    300