| ||||||||||
| 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,为什么我的总是Runtime Error呢?大家帮忙看看,谢谢!#include <stdio.h>
#include <stdlib.h>
int cmp(const void *a,const void *b)
{
return *(long int *)a - *(long int *)b;
}
int main( void )
{
long i, j, *cow, sets ;
scanf("%d", &sets ) ;
cow = ( long*)malloc(sizeof(long) );
for( i = 0; i < sets; ++i )
scanf("%d", &cow[i] ) ;
qsort( cow, sets, sizeof(long int), cmp) ;
printf("%ld\n", cow[sets/2] ) ;
return 0 ;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator