Advertisement
Ina5

CompareCharArrays

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