Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace common_end
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string[] firstLine = Console.ReadLine().Split(' ').ToArray();
  14.             string[] secondLine = Console.ReadLine().Split(' ').ToArray();
  15.  
  16.             int minLength = Math.Min(firstLine.Length, secondLine.Length);
  17.             int matchedWordsLeft = 0;
  18.             int mathedWordsRight = 0;
  19.        
  20.  
  21.             for (int i = 0; i < minLength; i++)
  22.             {
  23.                 if (firstLine[i] == secondLine[i])
  24.                 {
  25.                     matchedWordsLeft++;
  26.                 }
  27.  
  28.                 if (firstLine[firstLine.Length - 1 - i] == secondLine[secondLine.Length - 1 - i])
  29.                 {
  30.                     mathedWordsRight++;
  31.                 }
  32.             }
  33.  
  34.             Console.WriteLine(Math.Max(matchedWordsLeft,mathedWordsRight));
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement