Advertisement
DidiMilikina

06. Profit

Oct 31st, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int number_of_ones, number_of_twos, number_of_fives, total;
  8.     cin >> number_of_ones >> number_of_twos >> number_of_fives >> total;
  9.     for (int ones = 0; ones <= number_of_ones; ones++)
  10.     {
  11.         for (int twoes = 0; twoes <= number_of_twos; twoes++)
  12.         {
  13.             for (int fives = 0; fives <= number_of_fives; fives++)
  14.             {
  15.                 int current_total = ones * 1 + twoes * 2 + fives * 5;
  16.                 if (total == current_total)
  17.                 {
  18.                     printf("%d * 1 lv. + %d * 2 lv. + %d * 5 lv. = %d lv.",
  19.                         ones, twoes, fives, total);
  20.                     cout << endl;
  21.                 }
  22.             }
  23.         }
  24.     }
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement