vector 有点麻烦啊 能简单点么?

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>

using namespace std;

vector<int> v;
vector<int>::iterator it;
vector<int>::iterator te;

int main()
{
    int N;
    freopen("1.txt", "r", stdin);

    while(scanf("%d", &N) == 1)
    {
        v.clear();
        for(int i = 0 ; i < N ; i++)
        {
            int temp;
            scanf("%d", &temp);
            v.insert(v.end(), temp);
        }

        while( !v.empty() )
        {
            it = v.begin();
            for( te = v.begin() ; te != v.end(); te++)
            {
                if( *te < * it)
                    it = te;
            }
            printf("%d ", *it);
            v.erase(it);
        }

    }
    return 0;
}

 

posted on 2013-07-03 00:32  wwjyt  阅读(187)  评论(0编辑  收藏  举报