Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication4
- {
- class Program
- {
- static void Main(string[] args)
- {
- string aInput = Console.ReadLine();
- string bInput = Console.ReadLine();
- string aFirstPart = string.Empty;
- string aSecondPart = string.Empty;
- string bFirstPart = string.Empty;
- string bSecondPart = string.Empty;
- int acounter = 1;
- int bcounter = 1;
- int d = int.Parse(Console.ReadLine());
- int matches = 0;
- for (int i = 0; i < aInput.Length - 1; i++)
- {
- aFirstPart += aInput[i];
- int afirstPartSum = 0;
- foreach (var letter in aFirstPart)
- {
- afirstPartSum += (int)letter;
- }
- aSecondPart = aInput.Substring(i + 1);
- int asecondPartSum = 0;
- foreach (var letter in aSecondPart)
- {
- asecondPartSum += (int)letter;
- }
- acounter++;
- for (int j = 0; j < bInput.Length - 1; j++)
- {
- bFirstPart += bInput[j];
- int bfirstPartSum = 0;
- foreach (var letter in bFirstPart)
- {
- bfirstPartSum += (int)letter;
- }
- bSecondPart = bInput.Substring(j + 1);
- int bsecondSum = 0;
- foreach (var letter in bSecondPart)
- {
- bsecondSum += (int)letter;
- }
- bcounter++;
- int sum = (int)(Math.Abs((afirstPartSum * bsecondSum) - (bfirstPartSum * asecondPartSum)));
- if (sum <= d)
- {
- Console.WriteLine("({0}|{1}) matches ({2}|{3}) by {4} nakovs", aFirstPart,aSecondPart,bFirstPart,bSecondPart,sum);
- matches++;
- }
- }
- bFirstPart = string.Empty;
- bSecondPart = string.Empty;
- }
- if (matches == 0)
- {
- Console.WriteLine("No");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment