GMLY @ 2024-10-04 22:08:29
#include<bits/stdc++.h>
using namespace std;
int main(){
int a;
cin>>a;
double ans;
if(a<=150) ans=0.4463*a;
if(a>150&&a<=400) ans=0.4463*150+0.4663*(a-150);
else ans=ans=0.4463*150+0.4663*250+0.5663*(a-400);
cout<<fixed<<setprecision(1)<<ans;
}
by zhangfengyao @ 2024-10-08 21:18:03
可以参照此写法
#include<cstdio>
using namespace std;
int main()
{
int electricity;
double electricity_price;
scanf("%d",&electricity);
if(electricity<=150)
{
electricity_price=electricity*0.4463;
}
else if(electricity>150&&electricity<=400)
{
electricity_price=150*0.4463+(electricity-150)*0.4663;
}
else
{
electricity_price=150*0.4463+250*0.4663+(electricity-400)*0.5663;
}
printf("%.1f",electricity_price);
return 0;
}
by MG9527 @ 2024-10-13 17:11:21
@GMLY 怎么发贴呀
by chenzhibo00 @ 2024-10-30 15:36:37
121.5