Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- //входни данни
- int days;
- cin >> days;
- double totalFood;
- cin >> totalFood;
- double totalBiscuits = 0; //общо гр изядени бисквити за всички дни
- double totalEatenFoodForAllDays = 0;// общо изядени гр от двете за всички дни
- double totalEatenDog = 0; //общо изядени гр от кучето за всички дни
- double totalEatenCat = 0; // общо изядени гр от котката за всички дни
- //за всеки ден от 1 до последния -> изядено кол от кучето и изядено кол от котката
- for (int day = 1; day <= days; day++)
- {
- int eatenDog, eatenCat;
- cin >> eatenDog; //изядено от кучето
- totalEatenDog += eatenDog;
- cin >> eatenCat; //изядено от котката
- totalEatenCat += eatenCat;
- int totalEatenForDay = eatenDog + eatenCat; //общо за деня
- totalEatenFoodForAllDays += totalEatenForDay;
- //бисквити
- if (day % 3 == 0)
- {
- double biscuits = 0.10 * totalEatenForDay;
- totalBiscuits += biscuits;
- }
- }
- //отпечатвам статистиката
- cout << "Total eaten biscuits: " << round(totalBiscuits) << "gr." << endl;
- cout.setf(ios::fixed);
- cout.precision(2);
- cout << totalEatenFoodForAllDays / totalFood * 100 << "% of the food has been eaten." << endl;
- cout << totalEatenDog / totalEatenFoodForAllDays * 100 << "% eaten from the dog." << endl;
- cout << totalEatenCat / totalEatenFoodForAllDays * 100 << "% eaten from the cat." << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment