#include <iostream>
#include <vector>
using namespace std;

void PrintVec(vector<int> ivector)
{
    for(int i = 0; i < ivector.size(); i++)
    {
        cout << ivector[i] << " ";
    }
    cout<<endl;
}

int main() {
    int array[10] = {2,4,6,8,10,1,3,5,7,9};
    vector<int> ivector(array, array + 10);//數量,數值


    // 反轉
    reverse(ivector.begin(), ivector.end());
    PrintVec(ivector);
    // 排序
    sort(ivector.begin(), ivector.end());
    PrintVec(ivector);

    system("pause");
    return 0;
}

 

本篇參考 http://zh.wikipedia.org/wiki/Vector_%28STL%29

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 阿東 的頭像
    阿東

    ~阿東~的部落格

    阿東 發表在 痞客邦 留言(0) 人氣()