60,求助

P1422 小玉家的电费

justauser @ 2023-10-18 17:39:49

#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    double a;
    double b,c;
    cin>>a;
    if(a<=150)
    b=a*0.4463;
    if(a>150&&a<=400)
    b=150*0.4463+(a-150)*0.4663;
    if(a>=401){

    b=150*0.4463+249*0.4663+(a-401)*0.5663+0.5663;}
    printf("%.1f",b);
    return 0;
}

by Hyacinths @ 2023-10-18 17:59:23

把最后的一个算式改成b=150*0,4463+250*0.4663+(a-400)*0.5663


by Hyacinths @ 2023-10-18 18:01:04

#include<iostream>
#include<cstdio>
using namespace std;
int main(){
    double a;
    double b,c;
    cin>>a;
    if(a<=150) b=a*0.4463;
    if(a>150&&a<=400) b=150*0.4463+(a-150)*0.4663;
    if(a>=401) b=150*0,4463+250*0.4663+(a-400)*0.5663;
    printf("%.1lf",b);
    return 0;
}

by Hyacinths @ 2023-10-18 18:03:05

如果你觉得有帮助请关注我喵~


|