IvanBorisovG

TheSongsOfTheWheels

Sep 19th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.39 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace TheSongOfThe
  8. {
  9.     class TheSongOfThe
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int controlValue = int.Parse(Console.ReadLine());
  14.             int password = 0;
  15.             string pass = string.Empty;
  16.  
  17.             for (int a = 1; a <= 9; a++)
  18.             {
  19.                 for (int b = 1; b <= 9; b++)
  20.                 {
  21.                     for (int c = 1; c <= 9; c++)
  22.                     {
  23.                         for (int d = 1; d <= 9; d++)
  24.                         {
  25.                             if (a < b && c > d && (a * b + c * d) == controlValue)
  26.                             {
  27.                                 Console.Write($"{a}{b}{c}{d} ");
  28.                                 password++;
  29.                             }
  30.                             if (password == 4)
  31.                             {
  32.                                 pass = ($"{a}{b}{c}{d}");
  33.                             }
  34.                         }
  35.                     }
  36.                 }
  37.             }
  38.             Console.WriteLine();
  39.  
  40.             if (password < 4)
  41.             {
  42.                 Console.WriteLine("No!");
  43.             }
  44.             else
  45.             {
  46.                 Console.WriteLine($"Password: {pass}");
  47.             }
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment