第七章完结
This commit is contained in:
32
Chapter7/min_max.c
Normal file
32
Chapter7/min_max.c
Normal file
@@ -0,0 +1,32 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int max(int a, int b, int c)
|
||||
{
|
||||
int tmp;
|
||||
tmp = a > b ? a : b;
|
||||
|
||||
return tmp > c ? tmp : c;
|
||||
}
|
||||
|
||||
int min(int a, int b, int c)
|
||||
{
|
||||
int tmp;
|
||||
tmp = a < b ? a : b;
|
||||
|
||||
return tmp < c ? tmp : c;
|
||||
}
|
||||
|
||||
int dist(int a, int b, int c)
|
||||
{
|
||||
return max(a, b, c) - min(a, b, c);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int a = 3, b = 5, c = 10;
|
||||
|
||||
printf("result = %d\n", dist(a, b, c));
|
||||
|
||||
exit(0);
|
||||
}
|
||||
Reference in New Issue
Block a user