输入4位整形数,按从下到大的顺序依次排序
输入4位整形数,按从下到大的顺序依次排序。 求各位大虾!
2011-10-02 07:45
2011-10-02 07:53
2011-10-02 08:16
2011-10-02 09:08
2011-10-02 09:08

2011-10-02 09:28
2011-10-02 09:40
程序代码:#include <stdio.h>
#include <stdlib.h>
int compare(const void* p1, const void* p2)
{
return *(char*)p1 - *(char*)p2;
}
int main(void)
{
char buf[5];
gets(buf);
qsort(buf, sizeof buf - 1, sizeof(char), compare);
puts(buf);
}

2011-10-02 09:45
2011-10-02 09:53
2011-10-02 10:48