Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace jaggedArrays
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Enter the length of the first array: ");
- int n = int.Parse(Console.ReadLine());
- int[] array1 = new int[n];
- for(int i = 0;i < n; i++)
- {
- Console.Write("Element {0} = ", i + 1);
- array1[i] = int.Parse(Console.ReadLine());
- }
- Console.WriteLine("Enter the length of the second array: ");
- int k = int.Parse(Console.ReadLine());
- int[] array2 = new int[k];
- for (int i = 0; i < k; i++)
- {
- Console.Write("Element {0} = ", i + 1);
- array2[i] = int.Parse(Console.ReadLine());
- }
- bool isIt = true;
- if (n == k)
- {
- for (int i = 0; i < k; i++)
- {
- if(array1[i] != array2[i])
- {
- isIt = false;
- break;
- }
- }
- }
- else
- {
- Console.WriteLine("The arrays aren't equal!");
- }
- if(isIt == false)
- {
- Console.WriteLine("The arrays aren't equal!");
- }
- else
- {
- Console.WriteLine("The arrays are equal.");
- }
- Console.ReadLine();
- }
- }
- }
Add Comment
Please, Sign In to add comment