程式碼示例:
#include
float
sort(float
*a,float
*b,float
*c)
{
m;
if(*a>*b)
m=*a;
*a=*b;
*b=m;
}
if(*a>*c)
*a=*c;
*c=m;
if(*b>*c)
m=*b;
*b=*c;
return
0;
void
main()
i,j,k;
printf("Input
three
numbers:\n");
scanf("%f%f%f",&i,&j,&k);
sort
(&i,&j,&k);
printf("The
sorted
number
is:\n%f\n%f\n%f\n",i,j,k);
程式碼示例:
#include
float
sort(float
*a,float
*b,float
*c)
{
float
m;
if(*a>*b)
{
m=*a;
*a=*b;
*b=m;
}
if(*a>*c)
{
m=*a;
*a=*c;
*c=m;
}
if(*b>*c)
{
m=*b;
*b=*c;
*c=m;
}
return
0;
}
void
main()
{
float
i,j,k;
printf("Input
three
numbers:\n");
scanf("%f%f%f",&i,&j,&k);
sort
(&i,&j,&k);
printf("The
sorted
number
is:\n%f\n%f\n%f\n",i,j,k);
}