Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _05.Compare_Char_Arrays
- {
- class Program
- {
- static void Main(string[] args)
- {
- var arr1 = Console.ReadLine()
- .Split( ).Select(char.Parse).ToArray();
- var arr2 = Console.ReadLine()
- .Split( ).Select(char.Parse).ToArray();
- var minLength = Math.Min(arr1.Length, arr2.Length);
- OrderArraysFromBiggerToLower(arr1,arr2);
- }
- private static void OrderArraysFromBiggerToLower(char[] arr1Chars, char[] arr2Chars)
- {
- string result = string.Empty;
- for (int i = 0; i < arr1Chars.Length - 1; i++)
- {
- for (int j = 0; j < arr2Chars.Length - 1; j++)
- {
- //Console.WriteLine("{0}<->{1}",
- // arr1Chars[i], arr2Chars[j]);
- if (arr1Chars[i] == arr2Chars[j])
- {
- result = "equal";
- //Console.WriteLine("{0} -<", result);
- if (arr1Chars.Length<arr2Chars.Length)
- {
- Console.WriteLine(string.Join("", arr1Chars));
- Console.WriteLine(string.Join("", arr2Chars));
- }
- else if(arr1Chars.Length>arr2Chars.Length)
- {
- Console.WriteLine(string.Join("", arr2Chars));
- Console.WriteLine(string.Join("", arr1Chars));
- }
- }
- else if (arr1Chars[i]<arr2Chars[j])
- {
- result = "arr1";
- //Console.WriteLine("{0} -<", result);
- Console.WriteLine(string.Join("", arr1Chars));
- Console.WriteLine(string.Join("", arr2Chars));
- }
- else if (arr1Chars[i]>arr2Chars[j])
- {
- result = "arr2";
- //Console.WriteLine("{0} -<", result);
- Console.WriteLine(string.Join("", arr2Chars));
- Console.WriteLine(string.Join("", arr1Chars));
- }
- if (result != string.Empty) break;
- }
- if (result != string.Empty) break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment