Undertakers @ 2024-10-17 10:48:47
为什么这个过不了?```c
int main() { int e; double f1,f2,f3,sum1,sum2; scanf("%d",&e); while(e>=401) { int a=e-400; f1=a1.00.5663; sum1+=f1; e-=a; } if(e>=151&&e<=400) { int b=e-150; f2=b1.00.4663; e-=b; } if(e<=150) f3=e1.00.4463; sum2=sum1+f2+f3; printf("%.1f",sum2); return 0; }
by IYukinaI @ 2024-10-18 13:13:01
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
double a,ans=0;
cin>>a;
if(a<=150)//小于150千瓦时的情况
ans+=a*0.4463;
else if(a<=400)//大于150千瓦时且小于400千瓦时的情况
{
a=a-150;//千万要减掉,否则就会把150的也算进去
ans=66.945;
ans+=a*0.4663;
}
else//大于400千瓦时的情况
{
a=a-400;//同理
ans=183.52;
ans+=a*0.5663;
}
printf("%.1lf",ans);
return 0;
}
by Yyw1028 @ 2024-10-19 22:41:39
using namespace std; int main(){ int a=0; double b=0;// cin>>a; if(a<=150){ b = a0.4463; }else if(a>=151&&a<=400){ b += 1500.4463; b += (a-150)0.4663; }else{ b += 1500.4463; b += (400-150)0.4663; b += (a-400)0.5663; } b=int((b*10)+0.5)/10.0;