C++ 计算折扣价格:商品打折并舍去零头
#include
using namespace std;
int main() { int n; cin >> n;
double total = 0;
for (int i = 0; i < n; i++) {
double price;
int quantity;
cin >> price >> quantity;
total += price * quantity;
}
total *= 0.85;
total = int(total * 10 + 0.5) / 10.0;
cout << fixed << setprecision(1) << total << endl;
return 0;
}
原文地址: https://www.cveoy.top/t/topic/phaH 著作权归作者所有。请勿转载和采集!