Problem Description
编写一个程序,从输入的4个整数中找出最大值和最小值。
Input Description
在一行中输入4个整数,以空格分隔。
Output Description
在一行中按照格式“Largest = x, Smallest = y”输出所求的值。
Sample Input
21 43 10 35
Sample Output
Largest = 43, Smallest = 10
#include <stdio.h>
int
main(
void
)
{
int
a, b, c, d, Largest, Smallest;
scanf
(
"%d%d%d%d"
, &a, &b, &c, &d);
if
(a > b)
Largest = a;
else
Largest = b;
if
(Largest > c)
Largest = Largest;
else
Largest = c;
if
(Largest > d)
Largest = Largest;
else
Largest = d;
if
(a < b)
Smallest = a;
else
Smallest = b;
if
(Smallest < c)
Smallest = Smallest;
else
Smallest = c;
if
(Smallest < d)
Smallest = Smallest;
else
Smallest = d;
printf
(
"Largest = %d, Smallest = %d"
, Largest, Smallest);
return
0;
}