{
double x,y=0;
printf("input an number:");
scanf("%lf",&x);
if(x>1e6)
{
y+=(x-1e6)*0.06;x=1e6;
}
if(x>6e5)
{y+=(x-6e5)*0.015;x=6e5;
}
if(x>4e5)
{
y+=(x-4e5)*0.03;x=4e5;
}
if(x>2e5)
{
y+=(x-2e5)*0.05;x=2e5;
}
if(x>1e5)
{
y+=(x-1e5)*0.075;x=1e5;
}
y+=x*0.01;
printf("%f",y);
}
(2)
main()
{
double x,y=0;
long t;
printf("input an number:");
scanf("%lf",&x);
if(x>1e6) t=10;
else t=(long)(x-1)/100000;
switch(t)
{
case 10:y+=(x-1e6)*0.06;x=1e6;
case 9:case 8:case 7:
case 6:y+=(x-6e5)*0.015;x=6e5;
case 5:case 4:y+=(x-4e5)*0.03;x=4e5;
case 3:case 2:y+=(x-2e5)*0.05;x=2e5;
case 1:y+=(x-1e5)*0.075;x=1e5;
defualt: y+=x*0.01;
printf("%f",y);
}
妳運行看看!
錯了我在改!
應該沒錯!