Advertisement
aggressiveviking

Untitled

Feb 21st, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.87 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _12.TheSongOfThe_wheels
  4. {
  5.     class TheSongOfTheWheels
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int controlNumber = int.Parse(Console.ReadLine());
  10.            
  11.             int first = 0;
  12.             int second = 0;
  13.             int third = 0;
  14.             int fourth = 0;
  15.             int counter = 0;
  16.            
  17.             bool isTrue = false;
  18.             bool newRow = false;
  19.            
  20.             for (int i = 1; i <= 9; i++)
  21.             {
  22.                 for (int j = 1; j <= 9; j++)
  23.                 {
  24.                     for (int k = 1; k <= 9; k++)
  25.                     {
  26.                         for (int l = 1; l <= 9; l++)
  27.                         {
  28.                             if (i * j + k * l == controlNumber && i < j && k > l)
  29.                             {
  30.                                 newRow = true;
  31.                                 counter++;
  32.                                
  33.                                 Console.WriteLine($"{i}{j}{k}{l} ");
  34.                                
  35.                                 if (counter == 4)
  36.                                 {
  37.                                     isTrue = true;
  38.                                     first = i;
  39.                                     second = j;
  40.                                     third = k;
  41.                                     fourth = l;
  42.                                 }
  43.                             }
  44.                         }
  45.                     }
  46.                 }
  47.             }
  48.            
  49.             if (newRow)
  50.             {
  51.                 Console.WriteLine();
  52.             }
  53.             if (isTrue)
  54.             {
  55.                 Console.WriteLine($"Password: {first}{second}{third}{fourth}");
  56.             }
  57.             else
  58.             {
  59.                 Console.WriteLine("No!");
  60.             }
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement