10月7日 C语言 嵌套调用 输入4个整数,找出其中最大的数,用函数的嵌套调用来处理

来源:互联网 发布:js函数传递对象参数 编辑:程序博客网 时间:2024/05/21 18:43
#include<stdio.h>
int main()
{
int max4(int a,int b,int c,int d);
int a,b,c,d,max;
printf("please input 4 numbers:\n");
scanf("%d %d %d %d",&a,&b,&c,&d);
max=max4(a,b,c,d);
printf("max is %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);
}
阅读全文
0 0
原创粉丝点击