#include<stdio.h>
int main()
{
int t, income, flag;
scanf("%d", &t);
int tax_income = t - 3500;//tax_income为计税后的收入;
float a[6] = {0.03, 0.1, 0.2, 0.25, 0.3, 0.35};//存储小数用实型数组!!!
int b[6] = {1500-45, 4500-345, 9000-1245, 35000-7745, 55000-13745, 80000-22495};
int c[6] = {1500, 4500, 9000, 35000, 55000, 80000};
if(tax_income < 0)
{
printf("%d", t);
return 0;
}//易错点,应考虑工资未达到3500的情况;
if(tax_income > b[5])
{
income = (tax_income - b[5]) / (1 - 0.45) + 3500 + c[5];
}
else if(tax_income <= b[0])
{
income = tax_income / (1 - a[0]) + 3500;
}
else
{
for(int i = 0; i < 5; i++)
if(b[i] < tax_income && b[i + 1] >= tax_income)
{
flag = i;
break;
}
//printf("%d\n ", flag);
income = c[flag] + (tax_income - b[flag]) / (1 - a[flag + 1]) + 3500;
}
printf("%d", income);
return 0;
}
CCF认证 - 201612-2 - 工资计算 C语言代码实现(100分)
最新推荐文章于 2023-05-31 11:39:30 发布