方法1:int main()
{
int a = 2;
int b = 3;
int c = 1;
int tmp = 0;
scanf("%d%d%d",&a, &b,&c);
if(a>b)
{
tmp = a;
a = b;
b = tmp;
}
if(a>c)
{
tmp = a;
a = c;
c = tmp;
}
if(b>c)
{
tmp = b;
b = c;
c = tmp;
}
printf("a=%d b=%d c=%d\n", a, b, c);
return 0;
}
方法2:
int main()
{
int a, b, c, ret;
scanf("%d %d %d",&a,&b,&c);
if(a > b)
{
ret = a;
a = b;
b = ret;
}
if(a > c)
{
ret = a;
a = c;
c = ret;
}
if(b > c)
{
ret = b;
b = c;
c = ret;
}
printf("%d %d %d\n",a,b,c);
return 0;
}