用C语言将三个数按从大到小输出。

#include<stdio.h>
#include<stdlib.h>
int main()
{
 int a;
 int b;
 int c;
 int t;
 printf("请输入三个数字:\n");
 scanf_s("%d%d%d", &a, &b, &c);
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);
 system("pause");
 return 0;
}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/Richchigga/article/details/88728654