m0_52263497
2021-03-30 12:44
采纳率: 66.7%
浏览 21

c语言求救-请问运行后为什么会出现这种情况呢

#include<stdio.h>
int main()
{
int second_function(int parameter);
float profit,total_commission,else_,part_1,part_2,part_3,part_4,part_5,part_6;
int grade,parameter;
scanf("%float",profit);
if (profit<=100000) {grade=1;parameter=1;}
else if (profit<=200000)  {grade=2;parameter=2;}
else if (profit<=400000) {grade=3;parameter=3;}
else if (profit<=600000)  {grade=4;parameter=4;}
else if (profit<=1000000)  {grade=5;parameter=5;}
else grade=6;parameter=6;
switch(grade)
{
 case 6:part_1=(1.0/100)*(profit-1000000);else_=second_function(parameter);total_commission=part_1+else_;break;
 case 5:part_2=(1.5/100)*(profit-600000);else_=second_function(parameter);total_commission=part_2+else_;break;
 case 4:part_3=(3.0/100)*(profit-400000);else_=second_function(parameter);total_commission=part_3+else_;break;
 case 3:part_4=(5.0/100)*(profit-200000);else_=second_function(parameter);total_commission=part_4+else_;break;
 case 2:part_5=(7.5/100)*(profit-100000);else_=second_function(parameter);total_commission=part_5+else_;break;
 case 1:part_6=(10.0/100)*profit;
}
printf("The total commission is %f",total_commission);
return 0;
}
int second_function(int parameter)
{
float part_2,part_3,part_4,part_5,part_6=0.0;
part_2=part_3=part_4=part_5=part_6=0.0;
switch(parameter)
 {case 6:part_2=(1.5/100)*400000;
  case 5:part_3=(3.0/100)*200000;
  case 4:part_4=(5.0/100)*200000;
  case 3:part_5=(7.5/100)*100000;
  case 2:part_6==(10.0/100)*100000;
  return (part_2+part_3+part_4+part_5+part_6);
  }
}

 

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • 爱晚乏客游 2021-03-30 12:55
    已采纳

    第七行:scanf("%f", &profit);&符号没有加上。还有,你case1 的话,你的total_commission等于多少?在哪里初始化或者说明?

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题