2.1 个人所得税问题
#include <stdio.h>
#define TAXBASE3500
/*定义结构体*/ typedef struct{ long start; long end; double taxrate; }TAXTABLE; /*定义结构体数组*/ TAXTABLE TaxTable[]={0,1500,0.03), 41500,4500,0.101, (4500,9000,0.201,{9000, 35000,0.251, {35000,55000,0.301,{55000,80000,0.35), 480000,1e10,0.45}]}; /*CaculateTax()函数*/ double CaculateTax ( long profit) int i; double tax=0.0;profit-=TAXBASE; /*超过个税起征点的收入*/ for(i-0;i<sizeof (TaxTable) /sizeof (TAXTABLE); i++) { /*判断profit是否在当前的缴税范围内*/if(profit>TaxTable[i].start) { if (profit>TaxTable[i].end) /*profit超过当前的缴税范围*/ tax+=(TaxTable[i] .end-TaxTable[i] .start)*TaxTable[i] .taxrate; else /* profit未超过当前的缴税范围*/ tax+=(profit-TaxTable[i].start)*TaxTable[i].taxrate; ) profit-一TaxTable[i] .end; printf("征税范围:%6ld~%6ld 该范围内缴税金额:%6.2 超出该范围的 金额:%6ld\n" ,TaxTable[i].start, TaxTable[i].end, tax, (profit)>0 ? profit:0); return tax; } main( { long profit;double tax; printf("请输入个人收入金额:");scanf("号1d", &profit); tax = CaculateTax (profit); printf(”您的个人所得税为:号12.2f\n", tax);
}