Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class CompareCharArrays
- {
- static void Main()
- {
- string a = Console.ReadLine();
- string b = Console.ReadLine();
- char[] array1 = a.ToCharArray();
- char[] array2 = b.ToCharArray();
- int minLenght = Math.Min(array1.Length, array2.Length);
- int count1 = 0;
- int count2 = 0;
- for (int i = 0; i < minLenght; i++)
- {
- if (array1[i] < array2[i])
- {
- count1++;
- }
- if (array1[i] > array2[i])
- {
- count2++;
- }
- }
- if (count1 > count2)
- {
- Console.WriteLine("{0} is first.", a);
- Console.WriteLine("{0} is second.", b);
- }
- if (count1 == count2)
- {
- Console.WriteLine("They are the same!");
- }
- if (count1 < count2)
- {
- Console.WriteLine("{0} is first.", b);
- Console.WriteLine("{0} is second.", a);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement