在函数'Calculate_Duty'中:错误:禁用嵌套函数,使用-fnested-functions重新启用

时间:2012-11-15 05:12:35

标签: switch-statement

包括

/ *声明函数原型* /

float Calculate_Duty(int,int);

void Print_Duty(float);

int main(void)

{

/ *声明要在程序中使用的所有变量* /

char more_to_process;

int origin,category,quantity,num_ship = 0;

float unit_price;

浮动费用,责任,total_ship = 0;

float total_duty = 0,tax_rate = 0;

/ *开始执行程序* /

printf(“你有更多的海关表格需要处理吗?类型:Y表示是或N表示没有\ n”);

scanf(“%c”,& more_to_process);

while((more_to_process =='Y')&&(more_to_process!='N'))

{

printf(“货物的来源是什么?类型:1表示美国,2表示中国,3表示巴西\ n”);

scanf(“%d”,& origin);

printf(“什么类别的商品?类型:1代表食品,2代表服装,3代表木材\ n”);

scanf(“%d”,& category);

printf(“数量是多少?\ n”);

scanf(“%d”,& quantity);

printf(“单价是多少?\ n”);

scanf(“%f”,& unit_price);

total_ship = quantity * unit_price;

/ *计算出货的责任* /

tax_rate = Calculate_Duty(origin,category);

duty = tax_rate * total_ship;

total_duty + =责任;

/ *打印货件的责任* /

printf(“Origin \ t Category \ t Quantity \ t Unit Price \ t Shipment \ t Tax rate \ t Duty \ t \ n”);

printf(“%d \ t%d \ t \ t%d \ t \ t \ t%02.f \ t \ t \ t \ t%0.2f \ t \ t%0.2f \ t \ t \ t%0.2f \ t \ n” ,起源,

类别,数量,unit_price,total_ship,tax_rate,duty);

Print_Duty(duty);

printf(“你有更多的海关表格需要处理吗?输入:Y代表是,N代表没有\ n”);

scanf(“%c”,& more_to_process);

++ num_ship;

}

printf(“交易摘要:\ n”);

printf(“已处理的货件数量=%d \ n”,num_ship);

printf(“收集的总职责= $%0.2f \ n”,total_duty);

返回0;

}

/ *执行函数Calculate_Duty * /

float Calculate_Duty(int origin,int category)

{

浮动职责;

开关(原点)

{

/ *案例1适用于US * /

案例1:

开关(类别)

{

案例1:

占空比= 0;

中断;

案例2:

责任= 0;

中断;

案例3:

责任= .05;

中断;

}

中断;

/ *案例2适用于中国* /

案例2:

开关(类别)

{

案例1:

责任= .02;

中断;

案例2:

责任= .03;

中断;

案例3:

责任= .04;

中断;

}

中断;

/ *案例3适用于巴西* /

案例3:

开关(类别)

{

案例1:

责任= .01;

中断;

案例2:

责任= .02;

中断;

案例3:

责任= .08;

中断;

}

返回责任;

}

/ *执行Print_Duty功能* /

void Print_Duty(浮动税)

{

printf(“应付金额为$%0.2f \ n”,职责);

}

1 个答案:

答案 0 :(得分:0)

我可以看到,在返回任务之前,开关(原点)缺少一个}。

相关问题