为啥莓果!!!!!!!!!!

P1422 小玉家的电费

Zzz1209 @ 2024-11-14 16:10:49

为啥莓果!!!!!!!!

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n<1000){
    if(n<=150) cout<<n*0.4463<<endl;
    else
    {
        if((150<n)&&(n<140)) cout<<n*0.4663<<endl;
        else cout<<n*0.5663<<endl;
    }
    }
    return 0;
}

by LionBlaze @ 2024-11-14 16:12:12

@Zzz1209 if((150<n)&&(n<140))


by Zzz1209 @ 2024-11-14 16:40:06

@LionBlaze我就是这么做的!


by LionBlaze @ 2024-11-14 16:41:31

@Zzz1209@Zzz1209@Zzz1209@Zzz1209@Zzz1209[something]()


by LionBlaze @ 2024-11-14 16:42:14

@Zzz1209 那么好,你做得不对。

你觉得 150<nn<140 有可能同时成立吗?


by Zzz1209 @ 2024-11-14 17:02:38

?


by xuxingcheng @ 2024-11-18 21:08:50

代码:


#include<bits/stdc++.h>
using namespace std;

int main(){
    double x1=150*0.4463;
    double x2=250*0.4663;
    double n;
    cin>>n;
    if(n<=150){
        printf("%.1lf",n*0.4463);
        return 0; 
    }
    if(n<=400){
        n-=150;
        printf("%.1lf",x1+n*0.4663);
        return 0;
    }
    n-=400;
    printf("%.1lf",x1+x2+n*0.5663);
    return 0;
}

|