Sbw060426 @ 2024-10-27 14:20:54
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a;
scanf("%d", &a);
double m;
if (a<=150){
m=0.4463*a;
printf("%.1f", m);
}
if (a>150 && a<=400){
m=150*0.4463+(a-150)*0.4663;
printf("%.1f", m);
}
if (a>=401){
m=150*0.4463+250*0.4663+(m-400)*0.5663;
printf("%.1f", m);
}
return 0;
}
by gaohongyuan @ 2024-10-27 14:36:14
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a;
scanf("%d", &a);
double m;
if (a<=150){
m=0.4463*a;
printf("%.1f", m);
}
else if (a<=400){
m=150*0.4463+(a-150)*0.4663;
printf("%.1f", m);
}
else{
m=150*0.4463+250*0.4663+(a-400)*0.5663;
printf("%.1f", m);
}
return 0;
}
最后一个if里面的a-400写成了M-400