Advertisement
vinikol

05. Compare Char Arrays

Oct 6th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 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 _05.Compare_Char_Arrays
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             char[] firstArray = Console.ReadLine().Split(' ').Select(char.Parse).ToArray();
  14.             char[] secondArray = Console.ReadLine().Split(' ').Select(char.Parse).ToArray();
  15.  
  16.             if (firstArray.Length == secondArray.Length)
  17.             {
  18.                 if (firstArray[0] < secondArray[0])
  19.                 {
  20.                     Console.WriteLine(firstArray);
  21.                     Console.WriteLine(secondArray);
  22.  
  23.                 }
  24.                 else
  25.                 {
  26.                     Console.WriteLine(secondArray);
  27.                     Console.WriteLine(firstArray);
  28.                 }
  29.             }
  30.             else if (firstArray.Length > secondArray.Length)
  31.             {
  32.  
  33.                 Console.WriteLine(secondArray);
  34.                 Console.WriteLine(firstArray);
  35.             }
  36.             else
  37.             {
  38.                 Console.WriteLine(firstArray);
  39.                 Console.WriteLine(secondArray);
  40.  
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement