1.函数指针
类型名 (*指针名)(参数名1)
qsort函数:
#include <stdio.h>
#include <stdlib.h>
int MyCompare(const void *elem1,const void*elem2)
{
unsignedint *p1,*p2;
p1=(unsignedint *)elem1;
p2=(unsignedint *)elem2;
return(*p1%10)-(*p2%10);
}
#define NUM 5
int main()
{
unsignedint an[NUM]={8,123,11,10,4};
qsort(an,NUM,sizeof(an[0]),MyCompare);
for(inti=0;i<NUM;i++)
printf("%d",an[i]);
return0;
}