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