#include
int main()
{
int x;
float m;
scanf("%d",&x);
if(x<=50000)
m=0;
if(x>5000&&x<=8000)
m=(x-5000)*0.03;
if(x>8000&&x<=17000)
m=(x-8000)*0.10;
if(x>17000&&x<=30000)
m=(x-17000)*0.20;
else
m=(x-30000)*0.25
return 0;
}
这个else 如果不满足上边 if(x>17000&&x<=30000)就会直接走你的else,导致把之前算的结果覆盖掉,else 改成 if(x>3000)
#include<stdio.h>
int main()
{
int x;
float m;
scanf("%d",&x);
if(x<=50000)
m=0;
if(x>5000&&x<=8000)
m=(x-5000)*0.03;
if(x>8000&&x<=17000)
m=(x-8000)*0.10;
if(x>17000&&x<=30000)
m=(x-17000)*0.20;
if(x>3000)
m=(x-30000)*0.25 ;
return 0;
}