#include  

//qosrt函数的使用者得实现一个比较函数 
int int_cmp(const void * p1, const void * p2) 
{    
    return (*( int *)p1 > *(int *) p2);
} 

int main() 
{ 
    int arr[] = { 1, 3, 5, 7, 9, 2, 4, 6, 8, 0 };     
    int i = 0;          
    qsort(arr, sizeof(arr) / sizeof(arr[0]), sizeof (int), int_cmp);     
    for (i = 0; i< sizeof(arr) / sizeof(arr[0]); i++)     
    { 
        printf("%d ", arr[i]);
    }     
    printf("\n");   
    system("pause");
    return 0; 
}

MY_qsort

#include

int int_comp(void *p,void *q)
{
    return (*(int *)p>*(int *)q);
}
void swap(void *p,void *q,int size)
{
    int i = 0;
    for (i = 0; i < size; i++)
    {
        char temp = *((char*)p+i);
        *((char*)p + i) = *((char*)q + i);
        *((char*)q + i) = temp;
    }
}
void my_qsort(int *arr,int len,int size,int (*int_comp)(void *,void *))
{
    int i = 0;
    int j = 0;
    for (i = 0; i < len - 1; i++)
    {
        for (j = 0; j < len - i - 1; j++)
        {
            if (int_comp((char *)arr + j*size, (char *)arr + (j + 1)*size) > 0)
            {
                swap((char *)arr + j*size, (char *)arr + (j + 1)*size, size);
            }
        }
    }
}
int main()
{
    int arr[] = {1,3,5,7,9,2,4,6,8,0};
    int i = 0;
    int len = sizeof(arr) / sizeof(sizeof(arr[0]));
    int size = sizeof(int);
    my_qsort(arr,len,size,int_comp);
    for (i = 0; i < len; i++)
    {
        printf("%d",arr[i]);
    }
    printf("\n");
    system("pause");
    return 0;
}