Advertisement
Niicksana

The song of the wheels

Dec 9th, 2017
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.56 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 _6.The_song_of_the_wheels
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // Exam - 17 September 2017
  14.             int n = int.Parse(Console.ReadLine());
  15.  
  16.             int counter = 0;
  17.             string password = null;
  18.             for (int a = 1; a <= 9; a++)
  19.             {
  20.                 for (int b = 1; b <= 9; b++)
  21.                 {
  22.                     for (int c = 1; c <= 9; c++)
  23.                     {
  24.                         for (int d = 1; d < 9; d++)
  25.                         {
  26.                             if (n == a * b + c * d)
  27.                             {
  28.                                 if (a < b && c > d)
  29.                                 {
  30.                                     Console.Write("{0}{1}{2}{3} ", a, b, c, d);
  31.                                     counter++;
  32.  
  33.                                     if (counter == 4)
  34.                                     {
  35.                                         password = $"{a}{b}{c}{d}";
  36.                                     }
  37.                                 }
  38.                             }
  39.                         }
  40.                     }
  41.                 }
  42.             }
  43.  
  44.             Console.WriteLine();
  45.             if (password != null)
  46.             {
  47.                 Console.WriteLine("Password: {0}", password);
  48.             }
  49.  
  50.             else
  51.             {
  52.                 Console.WriteLine("No!");
  53.             }
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement