Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Exercise03
- {
- static void Main(string[] args)
- {
- char[] arryaOne = { 'a', 'b', 'c', 'd' };
- char[] arryaTwo = { 'a', 'b', 'b', 'd', 'e' };
- int lengthArrayOne = arryaOne.Length;
- int lengthArrayTwo = arryaTwo.Length;
- int minLength = Math.Min(lengthArrayOne, lengthArrayTwo);
- int equalLetters = 0;
- for (int i = 0; i < minLength; i++)
- {
- if (arryaOne[i] == arryaTwo[i])
- {
- equalLetters++;
- }
- else if (arryaOne[i] < arryaTwo[i])
- {
- Console.WriteLine("arrayOne is first lexicographically");
- break;
- }
- else
- {
- Console.WriteLine("arrayTwo is first lexicographically");
- break;
- }
- }
- if ((equalLetters == minLength) && (lengthArrayOne == lengthArrayTwo))
- {
- Console.WriteLine("Two arrays are the same");
- }
- else if ((equalLetters == minLength) && (lengthArrayOne < lengthArrayTwo))
- {
- Console.WriteLine("arrayOne is first lexicographically");
- }
- else if ((equalLetters == minLength) && (lengthArrayOne > lengthArrayTwo))
- {
- Console.WriteLine("arrayTwo is first lexicographically");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment