怎么去给vector qsort?(VC 能通过,DEV无法通过…………)
#include <iostream>#include <vector>
#include <cstdio>
using namespace std;
int cmp(const void *a,const void *b)
{
return *(int *)a-*(int *)b;
}
int find(vector<int> a,int Bfind)
{
int i;
for (i=0;i<a.size();i++)
{
if (a[i]==Bfind)
return 1;
}
return 0;
}
int main()
{
int n,i;
int temp;
cin>>n;
vector<int> a;
for (i=0;i<n;i++)
{
cin>>temp;
if (a.empty())
a.push_back(temp);
else if ( !find(a,temp))
a.push_back(temp);
}
qsort(a.begin(),a.size(),4,cmp);
for (i=0;i<a.size();i++)
cout<<a[i]<<" ";
return 0;
}