Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace LexicographicalComparison
- {
- class Program
- {
- static void Main(string[] args)
- {
- //getting the char arrays as strings
- string input1 = Console.ReadLine();
- string input2 = Console.ReadLine();
- //transition to arrays
- char[] array1 = input1.ToCharArray();
- char[] array2 = input2.ToCharArray();
- int i = 0;
- int j = 0;
- bool equal = false;
- while(i<array1.Length && j < array2.Length)
- {
- if(array1[i] > array2[j])
- {
- Console.WriteLine(input2);
- equal = false;
- break;
- }
- else if(array1[i] < array2[j])
- {
- Console.WriteLine(input1);
- equal = false;
- break;
- }
- else
- {
- equal = true;
- }
- }
- if(equal == true)
- {
- if(array1.Length < array2.Length)
- {
- Console.WriteLine(array1);
- }
- else if(array1.Length > array2.Length)
- {
- Console.WriteLine(array2);
- }
- else
- {
- Console.WriteLine("No difference! ");
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment