1、最大值
#include <stdio.h>
int main(void)
{
int a,b,c,d,m;
puts("please input four integers.");
printf("a = "); scanf("%d", &a);
printf("b = "); scanf("%d", &b);
printf("c = "); scanf("%d", &c);
printf("d = "); scanf("%d", &d);
m = a;
if (m == b && m == c && m == d)
puts("the integers are equal!\a");
else
{
if (b > m)
m = b;
if (c > m)
m = c;
if (d > m)
m = d;
printf("the larger is %d.\n", m);
}
return 0;
}
2、最小值
#include <stdio.h>
int main(void)
{
int a,b,c,d,m;
puts("please input four integers.");
printf("a = "); scanf("%d", &a);
printf("b = "); scanf("%d", &b);
printf("c = "); scanf("%d", &c);
printf("d = "); scanf("%d", &d);
m = a;
if (m == b && m == c && m ==d)
puts("the integers are equal!\a");
else
{
if (b < m)
m = b;
if (c < m)
m = c;
if (d < m)
m = d;
printf("the smaller integer is %d.\n", m);
}
return 0;
}