#includestdio.h
创新互联-专业网站定制、快速模板网站建设、高性价比布尔津网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式布尔津网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖布尔津地区。费用合理售后完善,十载实体公司更值得信赖。
#define MIN(a,b) ((a)(b)?(a):(b))
int main()
{float lr,jj;
scanf("%f",lr);
jj=0.1*MIN(lr,100000);
if(lr100000)jj+=0.075*MIN(lr-100000,100000);
if(lr200000)jj+=0.05*MIN(lr-200000,200000);
if(lr400000)jj+=0.03*MIN(lr-400000,200000);
if(lr600000)jj+=0.015*MIN(lr-600000,400000);
if(lr1000000)jj+=0.05*(lr-1000000);
printf("%g\n",jj);
return 0;
}
if里面条件写的有问题。else if(100000I=200000) 这个当I为300 000 时,前面100 000I这个是为真的,所以值为1,后面I=200 000时,就变成了1=200 000, 这个也是为真的,所以整个表达式是为真。所以执行的是total=I*0.075+2500.0; 结果为25000。
#include stdio.h
#include stdlib.h
void main(void)
{
double money,bouns;
printf("input the money, input a negitive number to leave:");
do{
scanf("%lf",money);
if(money=100000) bouns=money*0.1;
else if(money=200000) bouns=(money-100000)*0.075+100000*0.1;
else if(money=400000) bouns=(money-200000)*0.05+100000*0.075+100000*0.1;
else if(money=600000) bouns=(money-400000)*0.03+200000*0.05+100000*0.075+100000*0.1;
else if(money=1000000) bouns=(money-600000)*0.015+200000*0.03+200000*0.05+100000*0.075+100000*0.1;
else if(money100000) bouns=(money-1000000)*0.01+400000*0.015+200000*0.03+200000*0.05+100000*0.075+100000*0.1;
printf("bouns is %.2lf\n",bouns);
}
while(money=0);
}
#include stdio.h
#include stdlib.h
void main(void)
{
double money,bouns;
int temp;
printf("input the money, input a negitive number to leave:");
do{
scanf("%lf",money);
temp=money/100000;
switch(temp)
{
case 0: bouns=money*0.1; break;
case 1: bouns=(money-100000)*0.075+100000*0.1; break;
case 2:
case 3: bouns=(money-200000)*0.05+100000*0.075+100000*0.1; break;
case 4:
case 5: bouns=(money-400000)*0.03+200000*0.05+100000*0.075+100000*0.1; break;
case 6:
case 7:
case 8:
case 9: bouns=(money-600000)*0.015+200000*0.03+200000*0.05+100000*0.075+100000*0.1; break;
default: bouns=(money-1000000)*0.01+400000*0.015+200000*0.03+200000*0.05+100000*0.075+100000*0.1;
}
#include stdio.h
int main()
{
int z,i;
float sum=0;
printf("input money:");
scanf("%d",i);
if(i=100000)
z=1;
else if(i=200000i100000)
z=2;
else if(i=400000i200000)
z=4;
else if(i=600000i400000)
z=6;
else if(i=1000000i600000)
z=10;
else if(i1000000)
z=11;
switch(z)
{
case 11:sum+=(i-1000000)*0.01;i=1000000;
case 10:sum+=(i-600000)*0.015;i=600000;
case 6:sum+=(i-400000)*0.03;i=400000;
case 4:sum+=(i-200000)*0.05;i=200000;
case 2:sum+=(i-100000)*0.075;i=100000;
case 1:sum+=i*0.1;break;
}
printf("Bonus=%lf",sum);
return 0;
}
调好了 试试
#include stdio.h
int main()
{
float a,b;
printf("请输入销售额:");
scanf("%f",a);
switch((int) (a / 1000)) // 提取a的千位数字
{
case 0:
b = 0;
break;
case 1:
b = 2;
break;
case 2:
case 3:
case 4:
b = 5;
break;
default:
if(a == 5000.0) // 边界情况:销售额等于5000元
b = 5;
else
b = 10;
break;
}
float total = 500 + 500 * (b / 100);
printf("总工资为:%.2f\n",total);
return 0;
}
示范对话1:
示范对话2:
示范对话3:
示范对话4:
#includestdio.h
void main()
{
// int i;
double i;
double bonus,bon1,bon2,bon4,bon6,bon10;
bon1=100000*0.1;
bon2=bon1+100000*0.075;
bon4=bon2+100000*0.05;
bon6=bon4+100000*0.03;
bon10=bon6+100000*0.015;
//scanf("%d",i);
scanf("%lf",i);
if(i=100000)
bonus=i*0.1;
else if(i=200000)
bonus=bon1+(i-100000)*0.075;
else if(i=400000)
bonus=bon2+(i-200000)*0.05;
else if(i=600000)
bonus=bon4+(i-400000)*0.03;
else if(i=1000000)
bonus=bon6+(i-600000)*0.015;
else
bonus=bon10+(i-1000000)*0.01;
// 这里打印,有问题
// printf("%10.2f\n", bonus);
printf("%0.2lf\n", bonus);
getch();
}
运行结果: