回复 10楼 embed_xuel
我把它修改了,还是出现error c1010
回复 11楼 q619748128
你能分清什么叫运行错误?什么叫编译错误吗?
程序代码:/*
企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元
的部分按10%提成,高于10万元的部分,可提成7.5%;20万到40万之间时,高于20万元的部分,可提成5%;40万到60万之间
时高于40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可提成1.5%,高于100万元时,超过100万元的部
分按1%提成,从键盘输入当月利润I,求应发放奖金总数?
*/
#include <stdio.h>
// 奖金分配方案数据结构
typedef struct _Distribution
{
double low; // 下限
double high; // 上限
double percentage; // 百分比
} Distribution;
// 奖金分配方案表
const Distribution distribution[] =
{
{ 0.0, 10.0, 10.0},
{ 10.0, 20.0, 7.5},
{ 20.0, 40.0, 5.0},
{ 40.0, 60.0, 3.0},
{ 60.0, 100.0, 1.5},
{100.0, 1000.0, 1.0}
};
// 函数原型
double Get_Profits(void);
// 程序主入口
void main(void)
{
double profits; // 利润
double bonus; // 奖金
int rank; // 奖金等级
while (profits = Get_Profits())
{
printf_s("您输入的利润总额为: %.4f(万元)\n", profits);
bonus = 0.0;
for (rank = 0; !((profits > distribution[rank].low) && (profits <= distribution[rank].high)); ++rank)
{
bonus += (distribution[rank].high - distribution[rank].low) * distribution[rank].percentage / 100.0;
}
bonus += (profits - distribution[rank].low) * distribution[rank].percentage / 100.0;
printf_s("本期奖金总额为: %.2f(元)\n\n", bonus * 10000.0);
}
}
double Get_Profits(void)
{
double profits;
do
{
printf_s("请输入利润总额(单位万元): ");
profits = 0.0;
if ((scanf_s("%lf", &profits) < 1) || (profits < 0))
{
printf_s("输入数据不合法, 请重新输入!\n\n");
fflush(stdin);
}
} while (profits < 0);
return profits;
}

程序代码:/*
时间:2011年10月18日11:20:53
题目:习题4.10 企业发放的奖金根据利润提成,从键盘输入当月利润I,求应发奖金总数。
要求:用if语句编程序
*/
# include <stdio.h>
int main()
{
double profit,bonus=0;
printf("输入当月利润I:");
scanf("%lf",&profit);
if(profit>1000000)
{
bonus = 1.0/100*(profit-1000000);
profit = 1000000;
}
if(profit<=1000000 && profit>600000)
{
bonus += 1.5/100*(profit-600000);
profit = 600000;
}
if(profit<=600000 && profit>400000)
{
bonus += 3.0/100*(profit-400000);
profit = 400000;
}
if(profit<=400000 && profit>200000)
{
bonus += 5.0/100*(profit-200000);
profit = 200000;
}
if(profit<=200000 && profit>100000)
{
bonus += 7.5/100*(profit-100000);
profit = 100000;
}
if(profit<=100000 && profit>=0)
{
bonus += 10.0/100*profit;
}
printf("可获得奖金总数为%lf\n",bonus);
return 0;
}
/*
在VC++6.0中的输出结果为:
————————————
输入当月利润I:100000
可获得奖金总数为10000.000000
Press any key to continue
输入当月利润I:200000
可获得奖金总数为17500.000000
Press any key to continue
输入当月利润I:400000
可获得奖金总数为27500.000000
Press any key to continue
输入当月利润I:600000
可获得奖金总数为33500.000000
Press any key to continue
输入当月利润I:1000000
可获得奖金总数为39500.000000
Press any key to continue
输入当月利润I:2000000
可获得奖金总数为49500.000000
Press any key to continue
————————————
*/
