Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class LetterByLetter
- {
- static void Main()
- {
- Console.WriteLine("Enter size for the first array: ");
- int One = int.Parse(Console.ReadLine());
- Console.WriteLine();
- Console.WriteLine("Type the word letter by letter.");
- char [] arrOne = new char[One];
- for(int index = 0; index < One; index++)
- {
- arrOne [index] = char.Parse(Console.ReadLine());
- }
- Console.WriteLine();
- Console.WriteLine("Enter size for the second array: ");
- int Two = int.Parse(Console.ReadLine());
- Console.WriteLine();
- Console.WriteLine("Type the word letter by letter.");
- char[] arrTwo = new char [Two];
- for(int index = 0; index < Two; index++)
- {
- arrTwo [index] = char.Parse(Console.ReadLine());
- }
- bool even = true;
- int maxLenght;
- if(One > Two)
- {
- maxLenght = Two;
- }
- else if (One < Two)
- {
- maxLenght = One;
- }
- else
- {
- maxLenght = One;
- }
- for (int index = 0; index < maxLenght; index++)
- {
- if (arrOne[index] < arrTwo[index])
- {
- Console.WriteLine("The first array is lexicografically first.");
- even = false;
- break;
- }
- else if (arrOne[index] > arrTwo[index])
- {
- Console.WriteLine("The second array is lexicografically first.");
- even = false;
- break;
- }
- else
- {
- even = true;
- continue;
- }
- }
- if (even == true)
- {
- if (One < Two)
- {
- Console.WriteLine("The first array is lexicografically first.");
- }
- else if (One > Two)
- {
- Console.WriteLine("The second array is lexicografically first.");
- }
- else
- {
- Console.WriteLine("Both arrays are even.");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement