描述花花生病了妈妈去给花花买儿童止咳糖浆。一瓶儿童止咳糖浆的规格及用法如下所示一般花花咳嗽需要5天才能痊愈。止咳糖浆规格:每瓶120毫升每日3次10岁以上儿童:每次25毫升7-10岁儿童:每次15毫升3-6岁儿童:每次5毫升。请根据止咳糖浆的规格以及花花的年龄计算写一个程序计算如果花花要痊愈妈妈至少要买几瓶止咳糖浆?输入描述一个整数代表花花的年龄花花的年龄在3岁以上输出描述一个整数代表妈妈最少需要
#include <iostream>
using namespace std;
int main() {
int age;
cin >> age;
int syrupPerDay;
if (age >= 10) {
syrupPerDay = 25;
} else if (age >= 7) {
syrupPerDay = 15;
} else {
syrupPerDay = 5;
}
int days = 5;
int syrupPerBottle = 120;
int totalSyrup = syrupPerDay * days;
int bottles = (totalSyrup + syrupPerBottle - 1) / syrupPerBottle;
cout << bottles << endl;
return 0;
}
原文地址: http://www.cveoy.top/t/topic/iPem 著作权归作者所有。请勿转载和采集!