信息學奧賽C++語言:最大數max(x,y,z)

【題目描述】
在這裏插入圖片描述

【輸入】
輸入a,b,c。

【輸出】
求m,保留到小數點後三位。

【輸入樣例】
1 2 3

【輸出樣例】
0.200

代碼

#include<cstdio>
using namespace std;
int max(int a,int b,int c);
    int a,b,c;
    double m;
int main()
{
    scanf("%d%d%d",&a,&b,&c);
    m=1.0*max(a,b,c)/(max(a+b,b,c)*max(a,b,b+c));
    printf("%.3lf\n",m);
    return 0;
}
int max(int a,int b,int c)
{
    int temp=a;
    if(a<b)
    temp=b;
    if(temp<c)
    temp=c;
    return temp;
 
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章