Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- using namespace std;
- int main() {
- int days, dailyDogFood, dailyCatFood, eatenDogsFood = 0, eatenCatsFood = 0;
- cin >> days;
- double availableFood, cookies = 0;
- cin >> availableFood;
- for (int i = 1; i <= days; i++) {
- cin >> dailyDogFood >> dailyCatFood;
- if (i % 3 == 0) {
- cookies += 0.1 * (dailyDogFood + dailyCatFood);
- }
- eatenDogsFood += dailyDogFood;
- eatenCatsFood += dailyCatFood;
- }
- double totalEatenFood = eatenDogsFood + eatenCatsFood;
- printf("Total eaten biscuits: %igr.\n", (int)round(cookies));
- printf("%.2f%% of the food has been eaten.\n", 100.0 * totalEatenFood / availableFood);
- printf("%.2f%% eaten from the dog.\n", 100.0 * eatenDogsFood / totalEatenFood);
- printf("%.2f%% eaten from the cat.\n", 100.0 * eatenCatsFood / totalEatenFood);
- return 0;
- }
Advertisement
Advertisement