个税=应纳税收入×对应的税率-速算扣除数
#include float foo(float s, float *base, float *reduce, float *rate, float p) { float t = 0; int i; if (s > p) { for (i = 0; base[i] != -1; i++) if ((s - p) <= base[i]) break; t = (s - p) * rate[i-1] / 100 - reduce[i-1]; } printf("[%.0f] Tax: %7.2f, Rate: %4.2f%%n", p, t, 100 * t / s); return t; } int main(void) { float base_org[10] = {0, 500, 2000, 5000, 20000, 40000, 60000, 80000, 100000, -1}; float reduce_org[9] = {0, 25, 125, 375, 1375, 3375, 6375, 10375, 15375}; float rate_org[9] = {5, 10, 15, 20, 25, 30, 35, 40, 45}; float base[8] = {0, 1500, 4500, 9000, 35000, 55000, 80000, -1}; float reduce[7] = {0, 105, 555, 1005, 2755, 5505, 13505}; float rate[7] = {3, 10, 20, 25, 30, 35, 45}; float s, tax_org, tax; printf("Pls intput salary w/o INSURANCE,PENSION,HOUSING FUND: "); scanf("%f", &s); tax_org = foo(s, base_org, reduce_org, rate_org, 2000); tax = foo(s, base, reduce, rate, 3500); printf("Salary: %8.2f, Reduced Tax: %4.2fn", s, tax_org - tax); return 0; }
@t400:~# ./a.out Pls intput salary w/o INSURANCE,PENSION,HOUSING FUND: 6000 [2000] Tax: 475.00, Rate: 7.92% [3500] Tax: 145.00, Rate: 2.42% Salary: 6000.00, Reduced Tax: 330.00
第1,2个图,能否画一个0延续到10万的range学习一下?多谢!
LikeLike