Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Problem3CharArrayCompare
- {
- static void Main()
- {
- string str1 = Console.ReadLine();
- char[] arr1 = str1.ToCharArray();
- int arr1Length = arr1.Length;
- string str2 = Console.ReadLine();
- char[] arr2 = str2.ToCharArray();
- int arr2Length = arr2.Length;
- bool equal = true;
- if(arr1Length != arr2Length)
- {
- equal = false;
- if(arr1Length>arr2Length)
- {
- Console.WriteLine("The first array is lexicographically first");
- }
- else
- {
- Console.WriteLine("The second array is lexicographically first");
- }
- }
- else
- {
- for (int i = 0; i < arr1Length; i++)
- {
- if(arr1[i] == arr2[i])
- {
- continue;
- }
- else
- {
- equal = false;
- if (arr1[i] > arr2[i])
- {
- Console.WriteLine("The second array is lexicographically first");
- }
- else
- {
- Console.WriteLine("The first array is lexicographically first");
- }
- }
- }
- }
- if (equal == true)
- {
- Console.WriteLine("The two arrays are equal lexicographically");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement