Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class CompareTwoCharArrays
- {
- static void Main()
- {
- char[] arrayOne = new char[4];
- char[] arrayTwo = new char[4];
- bool equal = true;
- // Read the first array
- for (int i = 0; i < arrayOne.Length; i++)
- {
- arrayOne[i] = char.Parse(Console.ReadLine());
- }
- // Read the second array
- for (int i = 0; i < arrayTwo.Length; i++)
- {
- arrayTwo[i] = char.Parse(Console.ReadLine());
- }
- // Compair the elements
- for (int i = 0; i < arrayOne.Length; i++)
- {
- if ((arrayOne[i] != arrayTwo[i]) && (arrayOne[i] < arrayTwo[i]))
- {
- equal = false;
- Console.WriteLine("The arrays are NOT equal! The first is lexicographically earlier!");
- break;
- }
- else if (arrayOne[i] != arrayTwo[i])
- {
- equal = false;
- Console.WriteLine("The arrays are NOT equal! The second is lexicographically earlier!");
- break;
- }
- }
- if (equal)
- {
- Console.WriteLine("The arrays are equal!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment