Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Globalization;
- using System.Threading;
- public class NakovsMatching
- {
- public static void Main()
- {
- Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
- checked
- {
- string wordFirst = Console.ReadLine();
- string wordSecond = Console.ReadLine();
- int distance = int.Parse(Console.ReadLine());
- bool foundMatchings = false;
- int firstSumLeft = 0;
- string firstLeftStr = string.Empty;
- for (int i = 0; i < wordFirst.Length - 1; i++)
- {
- firstLeftStr += wordFirst[i].ToString();
- firstSumLeft += wordFirst[i];
- int firstSumRight = 0;
- string firstRightStr = string.Empty;
- for (int j = i + 1; j < wordFirst.Length; j++)
- {
- firstRightStr += wordFirst[j].ToString();
- firstSumRight += wordFirst[j];
- }
- int secondSumLeft = 0;
- string secondLeftStr = string.Empty;
- for (int k = 0; k < wordSecond.Length - 1; k++)
- {
- secondLeftStr += wordSecond[k].ToString();
- secondSumLeft += wordSecond[k];
- int secondSumRight = 0;
- string secondRightStr = string.Empty;
- for (int l = k + 1; l < wordSecond.Length; l++)
- {
- secondRightStr += wordSecond[l].ToString();
- secondSumRight += wordSecond[l];
- }
- int result = Math.Abs((firstSumLeft * secondSumRight) - (firstSumRight * secondSumLeft));
- if (result <= distance)
- {
- foundMatchings = true;
- Console.WriteLine("({0}|{1}) matches ({2}|{3}) by {4} nakovs", firstLeftStr, firstRightStr, secondLeftStr, secondRightStr, result);
- }
- }
- }
- if (!foundMatchings)
- {
- Console.WriteLine("No");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement