酷代码 AI
菜单
服务商

C++程序:输入能量宝石与原核能量,精准算出武器图鉴数量!

```cpp #include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n; cin >> n; vector<int> gems(n); for (int i = 0; i < n; i++) { cin >> gems[i]; } int core; cin >> core; // 计算总能量值 int totalEnergy = core; for (int energy : gems) { totalEnergy += energy; } // 每100能量兑换一个武器图鉴 int weaponCount = totalEnergy / 100; cout << weaponCount << endl; return 0; } ``` 程序说明: 1. 读取能量宝石数量n 2. 读取n个能量宝石的能量值并存储到数组 3. 读取能量原核的能量值 4. 计算总能量值(所有宝石能量之和加上原核能量) 5. 每100能量兑换一个武器图鉴,使用整数除法计算 6. 输出武器图鉴数量 输入示例: ``` 5 50 30 20 40 60 200 ``` 输出示例: ``` 4 ``` 计算过程: 总能量 = 50+30+20+40+60+200 = 400 武器图鉴数量 = 400/100 = 4 ######[AI问答 | 296点数解答 | 2025-12-14 13:09:38]

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