#include <stdio.h>
//交换函数
swap(int * x,int * y)
{ int temp;
temp = *x;
*x=*y;
*y=temp;
}
main01()
{
int a,b,c;
a=10;
b=28;
c=15;
if(a<b) swap(&a,&b); // 保证a是大于b的数
if(a<c) swap(&a,&c); //保证a是大于c的数,所以a是最大的数
if(b<c) swap(&b,&c); //保证b是大于c的数,所以b 是第二大数,c 是最小数
printf("%d,%d,%d\n",a,b,c); //传值,传址
}
评论0