为了正常的体验网站,请在浏览器设置里面开启Javascript功能!

用函数调用求中最大值

2011-12-21 2页 doc 16KB 32阅读

用户头像

is_314369

暂无简介

举报
用函数调用求中最大值1.#include void main() { int max_4(int a,int b,int c,int d); int a,b,c,d,max; printf("Please enter 4 interder numbers:"); scanf("%d,%d,%d,%d",&a,&b,&c,&d); max=max_4(a,b,c,d); printf("max=%d\n",max); } int max_4(int a,int b,int c,int d) { int max_2...
用函数调用求中最大值
1.#include void main() { int max_4(int a,int b,int c,int d); int a,b,c,d,max; printf("Please enter 4 interder numbers:"); scanf("%d,%d,%d,%d",&a,&b,&c,&d); max=max_4(a,b,c,d); printf("max=%d\n",max); } int max_4(int a,int b,int c,int d) { int max_2(int x,int y); 注意:x,y均可以省略不写,或可以写成任意字符,对编译无影响! int m; m=max_2(a,b); m=max_2(m,c); m=max_2(m,d); return(m); } int max_2(int a,int b) { return(a>b?a:b); } 2.#include int max_4(int a,int b,int c,int d); 注意:可以对调用函数提前声明,以后就不用声明了! int max_2(int x,int y); void main() {int a,b,c,d,max; printf("Please enter 4 interder numbers:"); scanf("%d,%d,%d,%d",&a,&b,&c,&d); max=max_4(a,b,c,d); printf("max=%d\n",max); } int max_4(int a,int b,int c,int d) { int max_2(int x,int y); int m; m=max_2(a,b); m=max_2(m,c); m=max_2(m,d); return(m); } int max_2(int x,int y) { if(x>y) return x; else return y; } 3.#include int max_4(int a,int b,int c,int d) { int max_2(int x,int y); int m; m=max_2(a,b); m=max_2(m,c); m=max_2(m,d); return(m); 注意:可以先定义要调用的函数,以后就不必对调用函数声明了! } int max_2(int x,int y) { if(x>y) return x; else return y; } void main() {int a,b,c,d,max; printf("Please enter 4 interder numbers:"); scanf("%d,%d,%d,%d",&a,&b,&c,&d); max=max_4(a,b,c,d); printf("max=%d\n",max); }
/
本文档为【用函数调用求中最大值】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。 本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。 网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。

历史搜索

    清空历史搜索