输入四个整数,找出其中的最大值,用函数的嵌套调用来处理
#include<stdio.h>
int main()
{
int max4(int a,int b,int c,int d);
int a,b,c,d,max;
scanf("%d%d%d%d",&a,&b,&c,&d);
max=max4(a,b,c,d);
printf("max=%d\n",max);
return 0;
}
int max4(int a,int b,int c,int d)
{
int max2(int a,int b);
int m;
m=max2(a,b);
m=max2(m,c);
m=max2(m,d);
return (m);
}
int max2(int a,int b)
{
if(a>=b)
return a;
else
return b;
}
本文介绍了一个使用C语言实现的功能,该功能通过嵌套函数调用来找出四个输入整数中的最大值。主要分为两个函数:max2()用于比较两个数并返回较大者;max4()则利用max2()来确定四个数中的最大值。

1万+

被折叠的 条评论
为什么被折叠?



