int onedudetotal;
int total;
int cust;
int price;
int day;
double calculate(int avgcust, int avgprice, int days)
{
onedudetotal = (avgprice * days) * avgcust;
return onedudetotal;
};
int main()
{
cout << "Please enter days, average customers and days" << endl;
cin >> cust; price; day;
cout << calculate(cust, day, price) << endl;
}
在编译期间,我的代码在输入日期成本和价格时返回0。当输入5,120和50时它应该返回30000.可能是什么问题?
答案 0 :(得分:3)
你有:
cin >> cust; price; day; // reads 'cust' from user input
// evaluates price, day as expressions
// which do nothing
你的意思是:
cin >> cust >> price >> day;