Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace _05._Compare_Char_Arrays_Veronika
- {
- class Program
- {
- static void Main(string[] args)
- {
- char[] firstInput = Console.ReadLine().
- Split().Select(char.Parse).ToArray();
- char[] secondInput = Console.ReadLine().
- Split().Select(char.Parse).ToArray();
- int minLength = Math.Min(firstInput.Length, secondInput.Length);
- if (firstInput.Length == secondInput.Length)
- {
- for (int i = 0; i < firstInput.Length; i++)
- {
- if (firstInput[i] > secondInput[i])
- {
- Console.WriteLine(string.Join("", secondInput));
- Console.WriteLine(string.Join("", firstInput));
- break;
- }
- else
- {
- Console.WriteLine(string.Join("", firstInput));
- Console.WriteLine(string.Join("", secondInput));
- break;
- }
- }
- }
- else
- {
- for (int i = 0; i < minLength; i++)
- {
- if (firstInput.Length > secondInput.Length)
- {
- if (firstInput[i] == secondInput[i])
- {
- Console.WriteLine(string.Join("",secondInput));
- Console.WriteLine(string.Join("",firstInput));
- break;
- }
- else if (firstInput[i] > secondInput.Length)
- {
- Console.WriteLine(string.Join("", secondInput));
- Console.WriteLine(string.Join("", firstInput));
- break;
- }
- else
- {
- Console.WriteLine(string.Join("", firstInput));
- Console.WriteLine(string.Join("", secondInput));
- break;
- }
- }
- else if (firstInput.Length < secondInput.Length)
- {
- if (firstInput[i] == secondInput[i])
- {
- Console.WriteLine(string.Join("", firstInput));
- Console.WriteLine(string.Join("", secondInput));
- break;
- }
- else if (firstInput[i] > secondInput.Length)
- {
- Console.WriteLine(string.Join("", firstInput));
- Console.WriteLine(string.Join("", secondInput));
- break;
- }
- else
- {
- Console.WriteLine(string.Join("", secondInput));
- Console.WriteLine(string.Join("", firstInput));
- break;
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment