#include<stdio.h>
int main()
{
int x, y, z;
printf("Please enter three numbers:");
scanf_s("%d %d %d",&x,&y,&z);
int largest, smallest, middle, sum;
largest = (x > y ? x : y) > z ? (x > y ? x : y) : z;
smallest = (x < y ? x : y) < z ? (x < y ? x : y) : z;
sum = x + y + z;
middle = sum - largest - smallest;
printf("smallest:%d\n", smallest);
printf("largest:%d\n", largest);
printf("middle:%d\n", middle);
return 0;
}
C语言——输入三个数求最大最小以及中间数(条件运算符)
于 2023-11-04 15:06:42 首次发布