【发布时间】:2011-01-15 18:35:00
【问题描述】:
我刚开始学习 C++ 课程,我编写、编译、调试并运行了我的第一个程序:
// This program calculates how much a little league team spent last year to purchase new baseballs.
#include <iostream>
using namespace std;
int baseballs;
int cost;
int total;
int main()
{
baseballs, cost, total;
// Get the number of baseballs were purchased.
cout << "How many baseballs were purchased? ";
cin >> baseballs;
// Get the cost of baseballs purchased.
cout << "What was the cost of each baseball purchased? ";
cin >> cost;
// Calculate the total.
total = baseballs * cost;
// Display the total.
cout << "The total amount spent $" << total << endl;
return 0;
}
我遇到的唯一问题是,当我运行程序时,它无法显示总花费 (cout)。有人可以解释一下原因吗?
谢谢
杰夫 H - 佛罗里达州萨拉索塔
【问题讨论】:
-
请编辑、突出显示您的代码并按 { } 按钮以正确格式化。
标签: visual-c++