二、思路设计
三、代码实现
#include<bits/stdc++.h> using namespace std; #define TAXBASE 3500; typedef struct { long start; long end; double taxrate; }TAXTABLE; TAXTABLE TaxTable[] = {{0, 1500, 0.03}, {1500, 4500, 0.10}, {4500, 9000, 0.20}, {9000, 35000, 0.25}, {35000, 55000, 0.30}, {55000, 80000, 0.35}, {80000, 10000000000, 0.45}}; double CaculateTax(long profit){ int i; double tax = 0.0; profit -= TAXBASE; for(i = 0; i < sizeof(TaxTable) / sizeof(TAXTABLE); i ++){ if(profit > TaxTable[i].start){ if(profit > TaxTable[i].end){ tax += (TaxTable[i].end - TaxTable[i].start) * TaxTable[i].taxrate; } else{ tax += (profit - TaxTable[i].start) * TaxTable[i].taxrate; } profit -= TaxTable[i].end; printf("征收范围:%6ld~%6ld 该范围内缴纳金额:%6.2f 超出该范围的金额: %6ld \n", TaxTable[i].start, TaxTable[i].end, tax,(profit) > 0 ? profit : 0); } } return tax; } int main(){ long profit; double tax; printf("请输入个人收入金额: "); scanf("%ld", &profit); tax = CaculateTax(profit); printf("你的个人所得税为:%12.2f\n", tax); }
标签:end,TaxTable,profit,tax,long,start,5.11,打卡 From: https://www.cnblogs.com/binglinll/p/17392530.html