Advertisement
YavorGrancharov

Largest_Common_End(90%)

Oct 8th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace Largest_Common_End
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string[] arr = Console.ReadLine().Split().ToArray();
  11.             string[] arr2 = Console.ReadLine().Split().ToArray();
  12.  
  13.             int count = 0;
  14.             if (arr.Length > arr2.Length)
  15.             {
  16.                 Array.Reverse(arr);
  17.                 Array.Reverse(arr2);
  18.                 for (int i = 0; i < arr2.Length; i++)
  19.                 {
  20.                     if (arr2[i] == arr[i])
  21.                     {
  22.                         count++;
  23.                     }
  24.                 }
  25.             }            
  26.             else
  27.             {
  28.                 for (int i = 0; i < arr.Length; i++)
  29.                 {
  30.                     if (arr[i] == arr2[i])
  31.                     {
  32.                         count++;
  33.                     }
  34.                 }
  35.             }          
  36.             Console.WriteLine(count);
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement