Advertisement
Guest User

Untitled

a guest
May 29th, 2016
536
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. class LargestCommonEnd
  4. {
  5. static void Main(string[] args)
  6. {
  7. string[] wordsFirst = Console.ReadLine().Split(' ').ToArray();
  8. string[] wordsSecond = Console.ReadLine().Split(' ').ToArray();
  9. int countLeftRight = 0;
  10. int countRightLeft = 0;
  11. for (int i = 0; i < wordsFirst.Length && i < wordsSecond.Length; i++)
  12. {
  13. if (wordsFirst[i] == wordsSecond[i])
  14. {
  15. countLeftRight++;
  16. }
  17. }
  18. for (int j = 0; j < wordsFirst.Length && j < wordsSecond.Length; j++)
  19. {
  20. if (wordsFirst[wordsFirst.Length - 1 - j] == wordsSecond[wordsSecond.Length - 1 - j])
  21. {
  22. countRightLeft++;
  23. }
  24. }
  25. Console.WriteLine(countRightLeft > countLeftRight ? countRightLeft : countLeftRight);
  26.  
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement