Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class CompareArayys
- {
- /*Write a program that reads two arrays from the console
- and compares them element by element.*/
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- int m = int.Parse(Console.ReadLine());
- int[] arr1 = new int[n];
- int[] arr2 = new int[m];
- bool equal = true;
- if (m == n)
- {
- for (int i = 0; i < n; i++)
- {
- arr1[i] = int.Parse(Console.ReadLine());
- }
- for (int i = 0; i < m; i++)
- {
- arr2[i] = int.Parse(Console.ReadLine());
- }
- for (int i = 0; i < n; i++)
- {
- if (arr1[i] != arr2[i])
- {
- equal = false; break;
- }
- }
- }
- else
- {
- equal = false;
- }
- Console.WriteLine("Are the arrays equal? {0}", equal );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement