Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace hw1
  8. {
  9.     class Program
  10.     {
  11.      
  12.         static void Main(string[] args)
  13.         {
  14.             Queue<int> numbers = new Queue<int>();
  15.             int N = 3;
  16.             numbers.Enqueue(3); // очередь 3
  17.             numbers.Enqueue(5); // очередь 3, 5
  18.             numbers.Enqueue(8); // очередь 3, 5, 8
  19.  
  20.             if (numbers.Count() < N)
  21.             {
  22.  
  23.                 Console.WriteLine("NULL NULL");
  24.                 Console.ReadKey();
  25.                 return;
  26.             }
  27.             else
  28.             {
  29.  
  30.                 for (int i = 0; i < N; i++)
  31.                 {
  32.                     if (numbers.Count() > 0)
  33.                     {
  34.                         // получаем первый элемент очереди
  35.                         int queueElement = numbers.Dequeue(); //теперь очередь 5, 8
  36.                         Console.WriteLine(queueElement);
  37.                     }
  38.                 }
  39.  
  40.             }
  41.             Console.ReadKey();
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement