#include "stdio.h"
#include <math.h>
void split(int a[],int x)
{
int i=0;
while(x>0)
{
a[i++]=x%10;
x=x/10;
}
}
void sort(int a[])
{
int i,j,d;
for(i=0;i<4;i++)
{
for(j=0;j<4-i-1;j++)
{
if(a[j]<a[j+1])
{
d=a[j];
a[j]=a[j+1];
a[j+1]=d;
}
}
}
}
int compose(int a[])
{
int i,x=0;
for(i=0;i<4;i++)
x+=a[i]*pow(10,3-i);
return x;
}
void main()
{
int a[5],x;
printf("请输入4位的整数: ");
scanf("%d",&x);
split(a, x);
sort(a);
x=compose(a);
printf("最大数:%d\n",x);
}
温馨提示:答案为网友推荐,仅供参考