Advertisement
DidiMilikina

06.The song of the wheels

Oct 24th, 2017
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. //URL FOR THE TASK: https://judge.softuni.bg/Contests/Practice/Index/784#5
  2.  
  3. #include <iostream>
  4. #include <string>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int number;
  10.     cin >> number;
  11.  
  12.     int counter = 0;
  13.     int pass = 0;
  14.     string output = "";
  15.     for (int first_num = 1; first_num <= 9; first_num++)
  16.     {
  17.         for (int second_num = 1; second_num <= 9; second_num++)
  18.         {
  19.             for (int third_num = 1; third_num <= 9; third_num++)
  20.             {
  21.                 for (int fourht_num = 1; fourht_num <= 9; fourht_num++)
  22.                 {
  23.                     if (first_num * second_num + (third_num * fourht_num) == number)
  24.                     {
  25.                         if ((first_num < second_num) && (third_num > fourht_num))
  26.                         {
  27.                             cout << first_num << second_num << third_num << fourht_num << " ";
  28.                             counter++;
  29.  
  30.                             if (counter == 4)
  31.                             {
  32.                                 output = "" + std::to_string(first_num) + std::to_string(second_num) + std::to_string(third_num) + std::to_string(fourht_num);
  33.                             }
  34.                         }
  35.                     }
  36.                 }
  37.             }
  38.         }
  39.     }
  40.     cout << endl;
  41.     if (counter == 1)
  42.     {
  43.         cout << "No!" << endl;
  44.         return 0;
  45.     }
  46.     if (counter >= 4)
  47.     {
  48.         cout << "Password: " << output<< endl;
  49.     }
  50.     else
  51.     {
  52.         cout << "No!" << endl;
  53.     }
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement