|
谢谢斑竹的建议。。。不过我这个好像又没注意。。下次改。。。呵呵
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
template <class T>
class ARR
{
int m;
vector<T> vec ;
vector<T>::iterator it;
public:
ARR(T a[],int size)
{
vector<T> vec1(a,a+size);
vec=vec1;
}
void delsame()
{
sort(vec.begin(),vec.end());
it=unique(vec.begin(),vec.end());
vec.erase(it,vec.end());
}
void show()
{
for(vector<int>::iterator iter=vec.begin(); iter!=vec.end();iter++)
{
cout<<*iter<<"\t";
}
cout<<endl;
}
};
int main()
{
int b[]={1,2,2,3,3,4,4,5,6,6,7,7,8,8,9,10,10};
ARR<int> v(b,sizeof(b)/sizeof(b[0]));
v.show();
v.delsame();
v.show();
return 0;
} |
|