修改后的程序:
#include
int main()
{
void swap(int *e,int *f);
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
swap(&a,&b);
swap(&a,&c);
swap(&a,&d);
swap(&b,&c);
swap(&b,&d);
swap(&c,&d);
printf("%d %d",a,d);
return 0;
}
void swap(int *e,int *f)
{
int temp;
if(*e<*f)
{
temp=*e;*e=*f;*f=temp;
}
}
运行测试:
5 6 4 1
6 1
哎,你得传入地址才行