|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
很简单的问题。经典例题中发奖金的那道题。不知道为什么,我的结果输出一直是0,请问各位大神问题处在哪里了
#include<stdio.h>
void main()
{
long int i;
double bouns1,bouns2,bouns4,bouns6,bouns10,bouns;
printf("please enter you money:\n");
scanf("%ld",&i);
bouns1 = 100000*0.1;
bouns2 = bouns1 + 100000 * 0.075;
bouns4 = bouns2 + 200000 * 0.05;
bouns6 = bouns4 + 200000 * 0.03;
bouns10 = bouns6 + 400000 * 0.015;
if(i<100000)
{
bouns = i*0.1;
}
else if(i < 200000)
{
bouns = bouns1 + (i - 100000) * 0.075;
}
else if(i < 400000)
{
bouns = bouns2 + (i - 200000) * 0.05;
}
else if( i < 600000)
{
bouns = bouns4 + (i - 400000) * 0.03;
}
else if(i < 1000000)
{
bouns = bouns6 + (i - 600000) * 0.015;
}
else if(i > 1000000)
{
bouns = bouns10 +(i - 100000) * 0.1;
}
printf("\nyou money is bouns = %d yuan\n",bouns);
}
你定义的bouns 是double类型的
应该%f 输出
|
|