| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
请问,qsort的一些用法,long int和int怎么不一样如果用long int,就编译通不过,总是说cmp不对,如果把下面的所有的long int改为int就ac了,不明白为什么,明白的指点一下吧
#include <iostream.h>
#include <stdlib.h>
lont int cmp(const void *a,const void *b)
{
return *(lont int *)a - *(long int *)b;
}
void main()
{
int N;
cin>>N;
long int *a=new int [N];
for(int i=0;i<N;i++)
cin>>a[i];
qsort(a,N,sizeof(a[0]),cmp);
cout<<a[N/2]<<endl;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator