1 #include<iostream>
2 #include <math.h>
3 #define taxbase 3500
4 using namespace std;
5 /*typedef struct{
6 int id;
7 char name[20];
8 int age;
9 char address[50];
10 }user;*/
11 typedef struct{
12 long start;
13 long end;
14 double taxrate;
15 }taxtable;
16 taxtable T[]={{0,1500,0.03}, {1500,4500,0.1}, {4500,9000,0.2},
17 {9000,35000,0.25},{35000,55000,0.3},{55000,80000,0.35},{80000,1e10,0.45}};
18 double caculatetax(long profit)
19 {
20 int i;
21 double tax=0.0;
22 profit-=taxbase;
23 for(i=0;i<sizeof(T)/sizeof(taxtable);i++)
24 {
25 if(profit>T[i].start){
26 if(profit>T[i].end){
27 tax+=(T[i].end-T[i].start)*T[i].taxrate;
28 }
29 else{
30 tax+=(profit-T[i].start)*T[i].taxrate;
31 }
32 profit-=T[i].end;
33 cout<<"征收范围为"<<T[i].start<<"-"<<T[i].end<<"征收金额为:"<<tax<<endl;
34 }
35 }
36 return tax;
37 }
38 void main(){
39 long profit;
40 double tax;
41 /*user u1;
42 cout<<"请输入id"<<endl;
43 cin>>u1.id;
44 cout<<"请输入姓名"<<endl;
45 cin>>u1.name;
46 cout<<"请输入年龄"<<endl;
47 cin>>u1.name;
48 cout<<"请输入地址"<<endl;
49 cin>>u1.address;*/
50 cout<<"请输入收入金额:"<<endl;
51 cin>>profit;
52 tax=caculatetax(profit);
53 cout<<"个人所得税为:"<<tax;
54 }
![]()