czh1 @ 2023-11-18 12:26:03
#include<stdio.h>
int main(){
double x,f;
scanf("%lf",&x);
if(x<=150){
f=x*0.4463;
}else if(x>=151&&x<=400){
f=150*0.4463+(x-150)*0.4663;
}else{
f=150*0.4463+250*0.4663+(x-400)*0.5663;
}
printf("%.1lf",f+0.05);
return 0;
}
by huta0 @ 2023-11-18 12:44:48
#include<stdio.h>
int main(){
double x,f;
scanf("%lf",&x);
if(x<=150){
f=x*0.4463;
}
if(x>=151&&x<=400){
f=150*0.4463+(x-150)*0.4663;
}
if(x>400) {
f=150*0.4463+250*0.4663+(x-400)*0.5663;
}
printf("%.1lf",f+0.05);
return 0;
}
把else去掉应该就好了
by zyx1127 @ 2023-11-24 18:26:38
@huta0 还是不行
by Ysfu @ 2023-11-28 18:30:39
#include<stdio.h>
int main(){
double x,f;
scanf("%lf",&x);
if(x<=150){
f=x*0.4463;
}
else if(x>=151&&x<=400){
f=150*0.4463+(x-150)*0.4663;
}
else if(x>400) {
f=150*0.4463+250*0.4663+(x-400)*0.5663;
}
printf("%.1lf",f+0.05);
return 0;
}
试试吧