// 请编程,设计计算个人所得税的函数,返回应缴纳所得税的金额。免税额为3500,7级超额累进税率: // 全月应纳税所得额 税率 速算扣除数(元) // 全月应纳税额不超过1500元 3 % // 0 // 全月应纳税额超过1500元至4500元 10 % // 105 // 全月应纳税额超过4500元至9000元 20 % // 555 // 全月应纳税额超过9000元至35000元 25 % // 1005 // 全月应纳税额超过35000元至55000元 30 % // 2755 // 全月应纳税额超过55000元至80000元 35 % // 5505 // 全月应纳税额超过80000元 45 % // 13505 #include void *result(int, double *, int *); int main() { int pretexIncome; // 税前收入 double rates[8] = {0, 0.03, 0.1, 0.2, 0.25, 0.3, 0.35, 0.45}; // 税率数组 int deducts[8] = {0, 0, 105, 555, 1005, 2755, 5505, 13505}; // 速算扣除数数组 printf("请输入你的税前收入: "); scanf("%d", &pretexIncome); result(pretexIncome, rates, deducts); // int *res = result(pretexIncome, rates, deducts); // printf("%d%d", res[0], res[1]); // printf("你最后的所得为 %d ,你所缴纳的税额为 %d\n", result(pretexIncome, rates, deducts)[1], result(pretexIncome, rates, deducts)[0]); return 0; } void *result(int pretexIncomeArgs, double *rateArgs, int *deductArgs) { int level; // 税率等级 int tex; // 缴纳税额 int aftertexIncome; // 税后收入 int diff = pretexIncomeArgs - 3500; // 征税差值 if (diff <= 0) level = 0; else if (diff > 0 && diff <= 1500) level = 1; else if (diff > 1500 && diff <= 4500) level = 2; else if (diff > 4500 && diff <= 9000) level = 3; else if (diff > 9000 && diff <= 35000) level = 4; else if (diff > 35000 && diff <= 55000) level = 5; else if (diff > 55000 && diff <= 80000) level = 6; else if (diff > 80000) level = 7; tex = diff * rateArgs[level] - deductArgs[level]; aftertexIncome = pretexIncomeArgs - tex; printf("你最后的所得为 %d ,你所缴纳的税额为 %d\n", aftertexIncome, tex); // int outNums[2] = {(int *)aftertexIncome, (int *)tex}; // return *outNums; // 返回结果数组 }