酷代码 AI
菜单
服务商

巧用抽样称重法,C++ 程序算出整箱橘子重量!

```cpp #include <iostream> #include <iomanip> using namespace std; int main() { int m, n; cin >> m >> n; double totalWeight = 0; double weight; for (int i = 0; i < n; i++) { cin >> weight; totalWeight += weight; } double averageWeight = totalWeight / n; double boxWeight = averageWeight * m; cout << fixed << setprecision(1) << boxWeight << endl; return 0; } ``` ######[AI问答 | 135点数解答 | 2025-12-13 20:29:50]

相关提问
本站限时免费提问中
实用工具查看更多
Linux在线手册 [开发类]
Jquery在线手册 [开发类]
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]