求3个数最大值和最小值的差
代码块
int max(int a, int b, int c)
{
int max;
if (a>b)
max = a;
else
max = b;
if (c>max)
max = c;
return max;
}
int min(int a, int b, int c)
{
int min;
if (a<b)
min = a;
else
min = b;
if (c<min)
min = c;
return min;
}
int fnD(int a, int b, int c)
{
return max(a, b, c) - min(a, b, c);
}
int main()
{
printf("different=%d\n", fnD(1, 2,9));
system("pause");
return 0;
}
运行结果:
different=2
请按任意键继续…