Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //URL FOR THE TASK: https://judge.softuni.bg/Contests/Practice/Index/642#5
- #include <iostream>
- using namespace std;
- int main()
- {
- int number;
- cin >> number;
- int sum = 0;
- int multiplication = 0;
- int counter = 0;
- for (int i = 1; i <= 30; ++i)
- {
- for (int j = 1; j <= 30; ++j)
- {
- for (int k = 1; k <= 30; ++k)
- {
- sum = i + j + k;
- if ((i < j && j < k) && sum == number)
- {
- cout << i << " + "
- << j << " + "
- << k << " = "
- << number << endl;
- counter++;
- }
- multiplication = i * j * k;
- if ((i > j && j > k) && multiplication == number)
- {
- cout << i << " * "
- << j << " * "
- << k << " = "
- << number << endl;
- counter++;
- }
- }
- }
- }
- if (!counter)
- {
- cout << "No!" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment