用的是函数的嵌套调用来做的,先说一下,我将其从大到小输出了,这个地方改一下调用函数即可,问题不大,自行解决就行。
#include <stdio.h>
void exchange(int *q1,int *q2,int *q3)
{
void(swap)(int *p1,int *p2);
{
if(*q1<*q2)
{
swap(q1,q2);
}
if(*q1<*q3)
{
swap(q1,q3);
}
if(*q2<*q3)
{
swap(q2,q3);
}
}
}
void(swap)(int *p1,int *p2)
{
int temp;
temp=*p1;
*p1=*p2;
*p2=temp;
}
int main(void)
{
void exchange(int *q1,int *q2,int *q3);
int a,b,c,*p1,*p2,*p3;
scanf("%d%d%d",&a,&b,&c);
p1=&a,p2=&b;p3=&c;
exchange(p1,p2,p3);
printf("%d,%d,%d\n",a,b,c);
return 0;
}