Advertisement
Teodor92

03. LexiEqual

Jan 6th, 2013
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. /* Write a program that compares
  2.  * two char arrays lexicographically (letter by letter).
  3.  */
  4.  
  5. using System;
  6.  
  7. class CharCompare
  8. {
  9.     static void Main()
  10.     {
  11.         char[] firstArray = {'a','b','c','d','e','f','r' };
  12.         char[] secondArray = { 'a', 'b', 'c', 'd', 'e', 'f','g' };
  13.         bool areLexiEqual = true;
  14.         // to do len check
  15.         if (firstArray.Length == secondArray.Length)
  16.         {
  17.             for (int i = 0; i < firstArray.Length; i++)
  18.             {
  19.                 if (firstArray[i] != secondArray[i])
  20.                 {
  21.                     areLexiEqual = false;
  22.                 }
  23.             }
  24.             Console.WriteLine(areLexiEqual);
  25.         }
  26.         else
  27.         {
  28.             areLexiEqual = false;
  29.             Console.WriteLine(areLexiEqual);
  30.         }
  31.        
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement