📅  最后修改于: 2022-03-11 14:44:51.016000             🧑  作者: Mango
#include
using namespace std;
int main()
{
int numberOfItems;
int totalCalories = 0;
int caloriesForItem;
cout << "How many items did you eat today? ";
cin >> numberOfItems;
cout << "Enter the number of calories in each of the "
<< numberOfItems << " items eaten: " << endl;
for (int count = 1; count <= numberOfItems; count++)
{
cout << "Enter calorie: ";
cin >> caloriesForItem;
totalCalories += caloriesForItem;
}
cout << "Total calories eaten today = " << totalCalories;
return 0;
}