snrg.net
当前位置:首页 >> 用C语言编写一个求两个数最大值的函数,在主函数输... >>

用C语言编写一个求两个数最大值的函数,在主函数输...

int max(int a, int b){return a>b?a:b;}int main(){ int a,b,c; scanf("%d%d",&a,&b,&c); printf("%d\n", max(max(a,b),c)); return 0;}

#include int fun(int a,int b){ return (a > b ? a : b); } int main() { int a,b; printf("Input a b: "); scanf("%d %d",&a,&b); printf("max = %d",fun(a,b)); return 0; }

参考程序如下: #include#includeint max3num(int a,int b,int c);int max(int a,int b);int main() {int a,b,c,maxNumber;printf("Please input 3 numbers:");scanf("%d %d %d",&a,&b,&c);maxNumber=max3num(a,b,c);printf("The MAX number is:...

#include int max(int a,int b){return a>b?a:b;}int min(int a,int b){return amax(b,c)?max(a,b):max(b,c),min(a,b)

C语言代码如下: #include int main() { int a,b; printf("please enter two number:"); -----两个数字用空格隔开,以回车键结束输入。 scanf("%d %d",&a,&b);if(a>b) printf("The max is %d",a); else if(b>a) printf("The max is %d",b); else...

#include int mymax(int a,int b,int c){ if(a>b && a>c) return a; else if(b>a && b>c) return b; else return c;}int main(void){ int a,b,c,d,e; printf("Input 5 integers...\n"); scanf("%d%d%d%d%d",&a,&b,&c,&d,&e); printf("The MAX is...

1, int i,j,k; if(i>j&i>k); else if(j>k) i=j; else i=k; printf("%d",i);

第一种int max2(int a, int b){ return a>b?a:b;}int max3(int a, int b, int c){ return max2(a, max2(b, c));}第二种int max3(int a, int b, int c){ int max = a; if(max < b) max = b; if(max < c) max = c; return max;}

#include#define MAX(a,b) (a>b)?(a):(b);void main() { int a,b,c,d; scanf("%d%d%d",&a,&b,&c); d=MAX(MAX(a,b),c); printf("%d,%d,%d中最大的数是%d\n",a,b,c,d);}

#include "stdio.h"double max(double d[],int n){double m=d[0];for(int i=1;im)m=d[i];}return m;}int main(){int n;double d[100];scanf("%d",&n);for(int i=0;i

网站首页 | 网站地图
All rights reserved Powered by www.snrg.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com