STL练习程序(去除相同元素)

2023-05-16


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int testscore[] = {67, 56, 24, 78, 99, 87, 56};

void main()
{
vector<int> score(testscore,testscore+sizeof(testscore)/sizeof(int));
vector<int>::iterator it;

copy(score.begin(),score.end(),ostream_iterator<int>(cout,""));
cout<<endl;

sort(score.begin(),score.end());

copy(score.begin(),score.end(),ostream_iterator<int>(cout,""));
cout<<endl;

it=unique(score.begin(),score.end());
copy(score.begin(),it,ostream_iterator<int>(cout,""));

}

转载于:https://www.cnblogs.com/tiandsp/archive/2012/02/08/2342104.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

STL练习程序(去除相同元素) 的相关文章

随机推荐