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

C++实现计算吊桥可放置木头数量及总宽度

```cpp #include <iostream> using namespace std; int main() { int n; cin >> n; // 输入木头的数量 int count = 0; // 记录放到吊桥上的木头数量 int totalWidth = 0; // 记录放到吊桥上的木头总宽度 for (int i = 0; i < n; i++) { int length, width; cin >> length >> width; // 输入每块木头的长度和宽度 if (length >= 5 && totalWidth + width <= 10) { count++; totalWidth += width; } } cout << count << " " << totalWidth << endl; // 输出结果 return 0; } ``` ######[AI问答 | 200点数解答 | 2026-04-18 19:37:50]

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