frxbg

CompareCharArrays

Jun 3rd, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace _05CompareCharArrays
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             char[] firstArray = Console.ReadLine().Split().Select(char.Parse).ToArray();
  11.             char[] secondArray = Console.ReadLine().Split().Select(char.Parse).ToArray();
  12.  
  13.             int firstSize = 0;
  14.             int secondSize = 0;
  15.  
  16.             for (int i = 0; i < firstArray.Length; i++)
  17.             {
  18.                 firstSize += firstArray[i];
  19.             }
  20.  
  21.             for (int i = 0; i < secondArray.Length; i++)
  22.             {
  23.                 secondSize += secondArray[i];
  24.             }
  25.  
  26.             if (firstSize <= secondSize)
  27.             {
  28.             Console.WriteLine(string.Join("", firstArray));
  29.                 Console.WriteLine(string.Join("", secondArray));
  30.             }
  31.             else
  32.             {
  33.                 Console.WriteLine(string.Join("", secondArray));
  34.                 Console.WriteLine(string.Join("", firstArray));
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment