从键盘输入三个整数x,y和z,按从大到小的顺序输出它们的值。
输入三个整数x,y和z。
按从大到小的顺序输出它们的值。
20 16 18
20 18 16
...
#include
int main(void)
{
int a, b, c, temp;
scanf_s("%d%d%d", &a, &b, &c);
if (a < b) //若a>b,则交换a和b中内容
{
temp = a; //将a中内容咱存入temp
a = b; //将b中内容存入a中
b = temp; //将temp中内容存入b中
}
if (a < c) //若a>c,则交换a和c中内容
{
temp = a; //将a中内容咱存入temp
a = c; //将c中内容存入a中
c = temp; //将temp中内容存入c中
}
if (b < c) //若b>c,则交换b和c中内容
{
temp = b; //将b中内容咱存入temp
b = c; //将c中内容存入b中
c = temp; //将temp中内容存入c中
}
printf("%d %d %d
", a, b, c);
return 0;
}
留言与评论(共有 0 条评论) “” |