當前位置:編程學習大全網 - 電腦編程 - C語言怎麽算最大值?

C語言怎麽算最大值?

編寫壹個C程序,運行時輸入a,b,c三個值,輸出其中值最大者的步驟:

1、首先輸入三個數,求三個數中的最大值

#include<stdio.h>

int?main(){int?max(int?x,int?y,int?z);int?a,b,c,m;scanf("%d,%d,%d",&a,&b,&c);m=max(a,b,c);printf("the?max?number?is?%d\n",m);return?0;

}

2、然後輸入

int?max(int?x,int?y,int?z){int?max2(int?a,int?b);int?temp,result;temp=max2(x,y);result=max2(temp,z);

return(result);

}

3、最後輸入

int?max2(int?a,int?b){int?q;if(a>b)q=a;else?q=b;return(q);}即可。

  • 上一篇:汽車行業找工作,上哪個招聘網站比較靠譜
  • 下一篇:UG8.0 繪圖精度怎麽改啊?比如要改成0.001
  • copyright 2024編程學習大全網