阅读背景:

尝试使用C qsort函数时出现问题

来源:互联网 
#include <stdio.h>
#include <stdlib.h>

float values[] = { 4, 1, 10, 9, 2, 5, -1, -9, -2,10000,-0.05,-3,-1.1 };

int compare (const void * a, const void * b)
{
    return ( (int) (*(float*)a - *(float*)b) );
}

int main ()
{

    int i;

    qsort (values, 13, sizeof(float), compare);

    for (i = 0; i < 13; i++)
    {
        printf ("%f ",values[ i ]);
    }
    putchar('\n');

    return 0;
}
#include <stdio.h>
#include <stdlib.h>

float v



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: