源代码:
#include <iostream>
#include<vector>
using namespace std;
int main() {
vector<int>vec;//int型容器
int n;
cout << "请输入一组数字:" << endl;
while (cin >> n)
vec.push_back(n);//获取的数字压入容器
cout << "首尾和依次是:" << endl;
for (int i = 0;i <= vec.size() - 1;i++)
{
cout << vec[i] + vec[vec.size()-1-i] <<" "<< endl;
}
if (vec.size() % 2 != 0) {
cout << vec[vec.size()/2];
}
return 0;
}