位数大小排序

来源:百度知道 编辑:UC知道 时间:2024/05/22 02:17:11
程序说明:输入一个五位整数,对此整数中的五个数值进行从大到小的顺序排序,形成一个新的五位整数,并输出这个整数。
要求:用函数调用。
C程序啊

#include <stdio.h>
#include <stdlib.h>
int cmp(const void* a, const void* b)
{
return (int)(*(char*)b - *(char*)a);
}

int sort(int n)
{
char buf[8];
sprintf(buf, "%d", n);
qsort(buf, 5, 1, cmp);
return atoi(buf);
}
int main(void)
{
int n;
scanf("%d", &n);
if(9999 < n && n < 100000)
printf("%d\n", sort(n));
return 0;
}

什么语言的程序?
C不?