1 条题解

  • 0
    @ 2024-12-24 9:54:27

    C :

    #include <stdio.h>
    int main(){
    float weight;
    float money;
    scanf("%f",&weight);
    if(weight<=10)
    money=2.5;
    else
    money=2.5+(weight-10)*1.5;
    printf("%.1f\n",money);
    return 0;}
    

    C++ :

    #include<iostream>
    #include<cstdio>  //standard input output
    using namespace std;
    int main()
    {
        float w,fee;
        cin>>w;
        if (w<=10) fee=2.5;
        else
            fee=2.5+(w-10)*1.5;
        cout.precision(1);   //设置输出格式,小数点后保留1位
        cout.setf(ios::fixed);  
        cout<<fee<<endl;
        
        return 0;
    } 
    
    • 1

    信息

    ID
    1052
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者