Advertisement
Guest User

Untitled

a guest
Oct 5th, 2016
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 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 Array_Ex
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. string[] array1 = Console.ReadLine().Split(' ');
  14. string[] array2 = Console.ReadLine().Split(' ');
  15.  
  16. int leftCount = 0;
  17. int rightCount = 0;
  18.  
  19. int minLen = Math.Min(array1.Length, array2.Length);
  20.  
  21. for (int i = 0; i < minLen; i++)
  22. {
  23. if (array1[i] == array2[i]) leftCount++;
  24. }
  25.  
  26. int diff = Math.Max(array1.Length, array2.Length) - minLen;
  27.  
  28. for (int i = minLen - 1; i >= 0; i--)
  29. {
  30. if (array1.Length < array2.Length && array1[i] == array2[diff + i])
  31. rightCount++;
  32. else if (array2.Length <= array1.Length && array2[i] == array1[i + diff])
  33. rightCount++;
  34. }
  35.  
  36. Console.WriteLine(Math.Max(leftCount, rightCount));
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement