= = 感觉这个题没什么说的,没发现什么会坑的地方。
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector <int> E;
int N;
int temp;
int sum = 0;
cin >> N;
for (int i = 0; i < N; i++) {
cin >> temp;
E.push_back(temp);
if (i == 0)
sum += temp * 6 + 5;
else if (temp > E[i - 1]) //上升
{
sum += (temp - E[i - 1]) * 6 + 5;
}
else//下降
{
sum += (E[i - 1] - temp) * 4 + 5;
}
}
cout << sum;
}
本文分享了一段使用C++编写的程序代码,该程序能够根据输入的一系列整数计算并输出一个特定的分数总和。通过运用vector容器存储整数序列,并遍历这些整数来实现分数的累加计算。
1025

被折叠的 条评论
为什么被折叠?



