//程序功能:将vector里每对相邻的整数和按顺序输出
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
vector<int> NUM, Num;
int num, tem, ex;
cin >> num;
NUM.push_back(num);
while (cin >> tem) {
NUM.push_back(tem);
}
auto s = NUM.size();
for (decltype(s) i = 0; i < s; i += 2) {
if (s / 2 == 0) {
Num.push_back(NUM[i] += NUM[i + 1]);
}
else {
ex = Num[s - 1];
if(i != s-1) Num.push_back(NUM[i] += NUM[i + 1]);
else Num.push_back(ex);
}
}
for (auto &c : Num) {
cout << c;
}
system("pause");
return 0;
}
1 回答
- 1 回答
- 0 关注
- 1185 浏览
添加回答
举报
0/150
提交
取消