Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class CharArrays
- {
- static void Main()
- {
- //Write a program that compares two char arrays lexicographically (letter by letter).
- Console.Write("Enter length for first array n = ");
- int n = int.Parse(Console.ReadLine());
- Console.Write("Enter length for second array m = ");
- int m = int.Parse(Console.ReadLine());
- char[] firstArray = new char[n];
- char[] secondArray = new char[m];
- for (int i = 0; i < n; i++)
- {
- Console.WriteLine("enter letter for first array: ");
- firstArray[i] =char.Parse (Console.ReadLine());
- }
- for (int i = 0; i < m; i++)
- {
- Console.WriteLine("enter letter for second array: ");
- secondArray[i] = char.Parse(Console.ReadLine());
- }
- bool Same = true;
- if (n == m)
- {
- for (int i = 0; i < m; i++)
- {
- if (firstArray[i] != secondArray[i])
- {
- Same = false;
- }
- }
- }
- else if (n != m)
- {
- Same = false;
- }
- Console.WriteLine(Same);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment