Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace TheSongOfTheWheels
- {
- class Program
- {
- static void Main(string[] args)
- {
- int controlValue = int.Parse(Console.ReadLine());
- int combinationsCount = 0;
- int i = 0;
- int j = 0;
- int k = 0;
- int l = 0;
- int sum = 0;
- bool theFourth = false;
- bool row = false;
- for (int first = 1; first <= 9; first++)
- {
- for (int second = 1; second <= 9; second++)
- {
- for (int third = 1; third <= 9; third++)
- {
- for (int fourth = 1; fourth <= 9; fourth++)
- {
- sum = (first * second) + (third * fourth);
- if (first < second && third > fourth && sum == controlValue)
- {
- row = true;
- combinationsCount++;
- Console.Write($"{first}{second}{third}{fourth} ");
- if (combinationsCount == 4)
- {
- theFourth = true;
- i = first;
- j = second;
- k = third;
- l = fourth;
- }
- }
- }
- }
- }
- }
- if (row)
- {
- Console.WriteLine();
- }
- if (theFourth)
- {
- Console.WriteLine($"Password: {i}{j}{k}{l}");
- }
- else
- {
- Console.WriteLine("No!");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment