Advertisement
Bubeto

Untitled

Jan 15th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace Print_Even_Numbers
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. Queue<int> input = new Queue<int>(Console.ReadLine().Split().Select(int.Parse));
  12. int number = 0;
  13.  
  14. Queue<int> evenNum = new Queue<int>();
  15. while (input.Any())
  16. {
  17. number = input.Peek();
  18. if (number % 2 == 0)
  19. {
  20.  
  21. evenNum.Enqueue(number);
  22. input.Dequeue();
  23. }
  24. else
  25. {
  26. input.Dequeue();
  27. }
  28.  
  29. }
  30. Console.WriteLine(string.Join(", ",evenNum));
  31. }
  32.  
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement