Advertisement
Guest User

Untitled

a guest
Jan 9th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2. class CompareWords
  3. {
  4.     static void Main(string[] args)
  5.     {
  6.         int z = 0;
  7.         Console.WriteLine("Write first word ");
  8.         string firstWord = Console.ReadLine();
  9.         char[] firstArray = new char[firstWord.Length];
  10.         for (int i = 0; i < firstWord.Length; i++)
  11.         {            
  12.             firstArray[i] = firstWord[i];
  13.         }
  14.         Console.WriteLine("Write second word ");
  15.         string secondWord = Console.ReadLine();
  16.         char[] secondArray = new char[secondWord.Length];
  17.         for (int i = 0; i < secondWord.Length; i++)
  18.         {
  19.             secondArray[i] = secondWord[i];
  20.         }
  21.         if (firstWord.Length > secondWord.Length)
  22.         {
  23.             z = firstWord.Length;
  24.         }
  25.         else
  26.         {
  27.             z = secondWord.Length;    
  28.         }
  29.         for (int i = 0; i < z; i++)
  30.         {
  31.             bool compare = firstArray[i] == secondArray[i];
  32.             Console.WriteLine(firstArray[i] + " = " + secondArray[i] + " is " + compare);
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement