Advertisement
Guest User

CompareArayys

a guest
Jan 6th, 2013
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2. class CompareArayys
  3. {
  4.     /*Write a program that reads two arrays from the console
  5.     and compares them element by element.*/
  6.     static void Main()
  7.     {
  8.         int n = int.Parse(Console.ReadLine());
  9.         int m = int.Parse(Console.ReadLine());
  10.         int[] arr1 = new int[n];
  11.         int[] arr2 = new int[m];
  12.         bool equal = true;
  13.         if (m == n)
  14.         {
  15.             for (int i = 0; i < n; i++)
  16.             {
  17.                 arr1[i] = int.Parse(Console.ReadLine());
  18.             }
  19.             for (int i = 0; i < m; i++)
  20.             {
  21.                 arr2[i] = int.Parse(Console.ReadLine());
  22.             }
  23.             for (int i = 0; i < n; i++)
  24.             {
  25.                 if (arr1[i] != arr2[i])
  26.                 {
  27.                     equal = false; break;
  28.                 }
  29.             }
  30.         }
  31.         else
  32.         {
  33.             equal = false;
  34.         }
  35.         Console.WriteLine("Are the arrays equal? {0}", equal );
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement