m0_61828817 2021-11-04 13:37 采纳率: 70%
浏览 24
已结题

c++最后几句话不知道为什么一直错误

#include
using namespace std;
int main()
{
const int NUM = 5;
double prices[] = { 9.92, 6.32, 12.63, 5.95, 10.29 };
double units[5];
double amounts[5];
double total = 0;
for (int i = 0; i < NUM; i++){
cout << "Enter number of units" << endl;
cin >> units[i];
amounts[i] = prices[i] * units[i];
total = total + amounts[i];
}
cout << "Price Units Amount" << endl;
for (int i = 0; i < NUM; i++){
cout << prices[i] <<setw(15)<< units[i] <<setw(15) << amounts[i] << endl;
}
cout << "Total:" << total << endl;
system("PAUSE");

return 0;

}

  • 写回答

1条回答 默认 最新

  • qzjhjxj 2021-11-04 13:59
    关注

    代码没发现问题,头文件:

    #include <iostream>
    #include <iomanip>
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 11月12日
  • 已采纳回答 11月4日
  • 创建了问题 11月4日