Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace ConsoleApplication2
- {
- using System;
- class Program
- {
- static void Main()
- {
- string notEqual = "Arrays are not equal";
- //Input for arrays
- Console.Write("First array: ");
- string firstArr = Console.ReadLine();
- Console.Write("Second array: ");
- string secondArr = Console.ReadLine();
- int equalCharacters = 0;
- if (firstArr.Length == secondArr.Length)
- {
- for (int i = 0; i < firstArr.Length; i++)
- {
- if (firstArr[i] == secondArr[i])
- {
- equalCharacters++;
- }
- else
- {
- Console.WriteLine(notEqual);
- break;
- }
- }
- if (equalCharacters == firstArr.Length)
- {
- Console.WriteLine("Arrays are equal!");
- }
- }
- else
- {
- Console.WriteLine(notEqual);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement