这里先讲一种办法,后面想起来另外的再补充。
#include <stdio.h>
int main()
{
int a = 0;
int b = 0;
int c = 0;
scanf("%d %d %d", &a, &b, &c);
int t = 0;//中间变量,用于存放较小的那个值,防止被覆盖
if (a < b)
{
t = a;
a = b;
b = t;
}
if (a < c)
{
t = a;
a = c;
c = t;
}
if (b < c)
{
t = b;
b = c;
c = t;
}
printf("%d %d %d", a, b, c);
return 0;
}