相邻两个数

#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
int main()
{
    vector<unsigned> scores;
    for (decltype(scores.size()) ix = 0; ix < 11; ++ix) {
        scores.push_back(ix);
    }
    //sort(scores.begin(), scores.end());
    //for (vector<unsigned>::iterator it = scores.begin(); *it < scores.size(); it++) {
    //    cout<<it
    //}
    for (decltype(scores.size()) ix = 0; ix < scores.size()-1;ix+=2 ) {
        cout << scores[ix] + scores[ix + 1] << ' ';
    }
    if (scores.size() % 2 != 0) {
        cout << "最后一个" << endl;
    }


    system("pause");
}

猜你喜欢

转载自www.cnblogs.com/jingchu/p/10347394.html
今日推荐