Advertisement
silvana1303

print even numbers // queue

Sep 19th, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace advanced
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             int[] input = Console.ReadLine().Split().Select(int.Parse).ToArray();
  12.  
  13.             Queue<int> queue = new Queue<int>();
  14.  
  15.             for (int i = 0; i < input.Length; i++)
  16.             {
  17.                 if (input[i] % 2 == 0)
  18.                 {
  19.                     queue.Enqueue(input[i]);
  20.                 }
  21.             }
  22.  
  23.             Console.WriteLine(string.Join(", ", queue));
  24.         }
  25.     }
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement