60分求助

P1422 小玉家的电费

2011chen @ 2023-09-24 09:03:00

#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    if(n<=150){
        cout<<fixed<<setprecision(1)<<n*0.4463;
    }
    if(n>150&&n<=400){
        cout<<fixed<<setprecision(1)<<150*0.4463+(n-150)*0.4663;
    }
    if(n>=401){
        cout<<fixed<<setprecision(1)<<150*0.4463+250*0.4463+(n-400)*0.5663;
    }
}

by kun1145141919810 @ 2023-09-24 09:10:24

最后是250*0.4663,不是0.4463


by bailin_Wzy @ 2023-09-24 09:22:03

是滴,你自己打错了


by 2011chen @ 2023-09-24 12:16:04

@kun1145141919810 谢谢


|