Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5.  
  6. namespace srdr
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             List<int> numbers = Console.ReadLine()
  13.                  .Split()
  14.                  .Select(int.Parse)
  15.                  .ToList();
  16.                 if (numbers.All(x=>x%2==0))
  17.                 {
  18.                     Console.WriteLine("All numbers are even.");
  19.                 }
  20.                 else if (numbers.All(x=>x%2!=0))
  21.                 {
  22.                     Console.WriteLine("All numbers are odd.");
  23.                 }
  24.                 else
  25.                 {
  26.                     Console.WriteLine("The list contains both even and odd numbers.");
  27.                 }
  28.  
  29.            
  30.            
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement