马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<stdio.h>
int main(void)
{
double i,a1,a2,a3,a4,a5,a6,money;
printf("enter the profit");
scanf("%lf",&i);
a1=100000*0.1;
a2=a1+(100000)*0.075;
a3=a2+200000*0.05;
a4=a3+200000*0.03;
a5=a4+400000*0.015;
if(i<=100000)
{
money=i*0.1;
}
else if(i<=200000) money=a1+(i-100000)*0.075;
else if(i<=400000) money=a2+(i-200000)*0.05;
else if(i<=600000) money=a3+(i-400000)*0.03;[code]
#include<stdio.h>
int main(void)
{
double i,a1,a2,a3,a4,a5,a6,money;
printf("enter the profit");
scanf("%lf",&i);
a1=100000*0.1;
a2=a1+(100000)*0.075;
a3=a2+200000*0.05;
a4=a3+200000*0.03;
a5=a4+400000*0.015;
if(i<=100000)
{
money=i*0.1;
}
else if(100000<i<=200000) money=a1+(i-100000)*0.075;
else if(200000<i<=400000) money=a2+(i-200000)*0.05;
else if(400000<i<=600000) money=a3+(i-400000)*0.03;
else if(600000<i<=1000000) money=a4+(i-600000)*0.015;
else money=a5+(i-1000000)*0.01;
printf("%f",money);
return 0;
}
else if(i<=1000000) money=a4+(i-600000)*0.015;
else money=a5+(i-1000000)*0.01;
printf("%f",money);
return 0;
}[/code]
这两个代码只有else if里面的东西不同但是表示的范围是相同的,为什么输入一个数值时得到的答案不同呢?比如输入234000第一个得到192000但是第二个是205000
|