Advertisement
radidim

P05.PrintEvenNumbers (C# Shell App Paste)

Jul 5th, 2020
1,178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
  2. using System;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Collections.Generic;
  6.  
  7. namespace CSharp_Shell
  8. {
  9.  
  10.     public static class Program
  11.     {
  12.         public static void Main()
  13.         {
  14.            var numbers = Console
  15.            .ReadLine()
  16.            .Split(" ")
  17.            .Select(int.Parse)
  18.            .ToArray();
  19.            var queue = new Queue<int>();
  20.            foreach(var num in numbers)
  21.            {
  22.             queue.Enqueue(num);
  23.            }
  24.            var count=0;
  25.            while(queue.Count>count)
  26.            {
  27.             var num = queue.Dequeue();
  28.             if(num%2==0)
  29.             {
  30.                 count++;
  31.                 queue.Enqueue(num);
  32.             }
  33.            }
  34.            Console.WriteLine(String.Join(", ", queue));
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement