Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int r, s, c, maxJuice;
- cin >> r >> s >> c >> maxJuice;
- double juice = 0;
- int raspberries = 0, strawberries = 0, cherries = 0;
- for (int j = 0; j <= r; j++) {
- for (int k = 0; k <= s; k++) {
- for (int l = 0; l <= c; l++) {
- double currentJuice = 4.5 * j + 7.5 * k + 15 * l;
- if (juice < currentJuice && currentJuice <= maxJuice) {
- juice = currentJuice;
- raspberries = j;
- strawberries = k;
- cherries = l;
- }
- }
- }
- }
- cout << raspberries << " Raspberries, " << strawberries << " Strawberries, " << cherries << " Cherries. Juice: " << juice << " ml.\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement