Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Program
- {
- static void Main()
- {
- string[] firstArray = Console.ReadLine().Split();
- string[] secondArray = Console.ReadLine().Split();
- int counter = 0;
- if (firstArray.Length < secondArray.Length)
- {
- for (int i = 0; i < firstArray.Length; i++)
- {
- if (firstArray[i] == secondArray[i])
- {
- counter++;
- }
- else
- {
- break;
- }
- }
- }
- else
- {
- for (int i = 0; i < secondArray.Length; i++)
- {
- if (firstArray[i] == secondArray[i])
- {
- counter++;
- }
- else
- {
- break;
- }
- }
- }
- if (firstArray.Length < secondArray.Length)
- {
- for (int i = firstArray.Length - 1 ; i >= 0 ; i--)
- {
- int arrayDifference = Math.Abs(firstArray.Length - secondArray.Length);
- if (firstArray[i] == (secondArray[i + arrayDifference]))
- {
- counter++;
- }
- else
- {
- break;
- }
- }
- }
- else
- {
- for (int i = secondArray.Length -1 ; i >= 0 ; i--)
- {
- int arrayDifference = Math.Abs(firstArray.Length - secondArray.Length);
- if (secondArray[i] == (firstArray[i + arrayDifference]))
- {
- counter++;
- }
- else
- {
- break;
- }
- }
- }
- Console.WriteLine(counter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement