SHARE
TWEET

03. LexiEqual

Teodor92 Jan 6th, 2013 385 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top