#include<stdio.h>
void main()
{
unsigned long I,R,c,d1,d2,d3,d4,d5;
printf("please enter the value of profits:");
scanf("%lu",&I);
c=I/100000;d1=10000;d2=7500;d3=10000;d4=6000;d5=6000;
if(I>1e6) printf("R=%u",R=d1+d2+d3+d4+d5+(I-1e6)*1/100);
else
switch(c)
{
case 0: R=I*10/100;
case 1: R=d1+(I-1e5)*7.5/100;
case 2:
case 3: R=d1+d2+(I-2e5)*5/100;
case 4:
case 5: R=d1+d2+d3+(I-2e5)*3/100;
case 6:
case 7:
case 8:
case 9: R=d1+d2+d3+d4+(I-4e5)*1.5/100;
}
printf("R=%u\n",R);
}
这两个程序都是计算同一个题但是输入同一个数字输出却不同,各位帮我看下啊!到底是哪个错了?
#include<stdio.h>
void main()
{
unsigned long I,R,a,b,c,d,e;
printf("please enter the value of profits:");
scanf("%lu",&I);
a=10000;c=10000;b=7500;e=6000;d=6000;
if(I<=100000)
R=I*10/100;
else
if(100000<I<=2e5)
R=a+(I-100000)*7.5/100;
else if(200000<I<=4e5)
R=a+b+(I-20000)*5/100;
else if(400000<I<=6e5)
R=a+b+c+(I-400000)*3/100;
else if(600000<I<=1e6)
R=a+b+c+d+(I-600000)*1.5/100;
else if(I>1000000)
R=a+b+c+d+e+(I-1000000)*1/100;
printf("R=%lu",R);
}