Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- class LargestCommonEnd
- {
- static void Main(string[] args)
- {
- string[] wordsFirst = Console.ReadLine().Split(' ').ToArray();
- string[] wordsSecond = Console.ReadLine().Split(' ').ToArray();
- int countLeftRight = 0;
- int countRightLeft = 0;
- for (int i = 0; i < wordsFirst.Length && i < wordsSecond.Length; i++)
- {
- if (wordsFirst[i] == wordsSecond[i])
- {
- countLeftRight++;
- }
- }
- for (int j = 0; j < wordsFirst.Length && j < wordsSecond.Length; j++)
- {
- if (wordsFirst[wordsFirst.Length - 1 - j] == wordsSecond[wordsSecond.Length - 1 - j])
- {
- countRightLeft++;
- }
- }
- Console.WriteLine(countRightLeft > countLeftRight ? countRightLeft : countLeftRight);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement