酷代码 AI
菜单
服务商
DeepSeek字节豆包讯飞星火
更多选项

C++入门:数组排序求解最小时间总和

```cpp #include <iostream> #include <algorithm> using namespace std; int main() { int n; int times[100]; cin >> n; for (int i = 0; i < n; i++) { cin >> times[i]; } sort(times, times + n); int total = 0; for (int i = 0; i < 5; i++) { total += times[i]; } cout << total << endl; return 0; } ``` **解题思路**: - 🌟 读取n和所有时间数据 - 📊 使用`sort()`函数升序排列数组 - 🔢 累加排序后的前5个最小值 - ✅ 输出总和 ######[AI问答 | 183点数解答 | 2026-05-09 19:57:21]

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