1) 个人所得税起征点为3500元,若 S不超过3500,则不交税,3500元以上的部分才计算个人所得税,令 A= S-3500元;
2) A中不超过1500元的部分,税率3%;
3) A中超过1500元未超过4500元的部分,税率10%;
4) A中超过4500元未超过9000元的部分,税率20%;
5) A中超过9000元未超过35000元的部分,税率25%;
6) A中超过35000元未超过55000元的部分,税率30%;
7) A中超过55000元未超过80000元的部分,税率35%;
8) A中超过80000元的部分,税率45%;
例如,如果小明的税前工资为10000元,则 A=10000-3500=6500元,其中不超过1500元部分应缴税1500×3%=45元,超过1500元不超过4500元部分应缴税(4500-1500)×10%=300元,超过4500元部分应缴税(6500-4500)×20%=400元。总共缴税745元,税后所得为9255元。
已知小明这个月税后所得为 T元,请问他的税前工资 S是多少元。
对于所有评测用例,1 ≤ T ≤ 100000。
(这个题我一开始理解错了,所以有两种代码,第一个是求税前工资,第二个是求税后工资)
①参考代码:
#include <iostream>
using namespace std;
int main(){
double T,A;
cin >> T;
int s;
if ((T-3500)<=0)
{
s = T;
}
else
{
s = 3500;
A = T - 3500;
if (A <= 1500 * 0.97)
{
s += A / 0.97;
}
else
{
s += 1500;
A = A - 1500 * 0.97;
if (A <= 3000 * 0.9)
{
s += A/0.9;
}
else
{
s += 3000;
A = A - 3000 * 0.9;
if (A <= 4500 * 0.8)
{
s += A/0.8;
}
else
{
s += 4500;
A = A - 4500 * 0.8;
if (A <= 26000 * 0.75)
{
s += A/0.75;
}
else
{
s += 26000;
A = A - 26000 * 0.75;
if (A <= 20000 * 0.7)
{
s += A/0.7;
}
else
{
s += 20000;
A = A - 20000 * 0.7;
if (A <= 25000 * 0.65)
{
s += A/0.65;
}
else
{
s += 25000;
s += (A- 25000* 0.65)/ 0.55;
}
}
}
}
}
}
}
cout<<s;
return 0;
}
提交结果:
代码长度 | 编程语言 | 评测结果 | 得分 | 时间使用 | 空间使用 |
---|
934B | C++ | 正确 | 100 | 0ms | 512.0KB |
#include <iostream>
using namespace std;
//求税后
void main(){
int s, A;
cin >> s;
double result;
if (s<=3500)
{
result = s;
}
else
{
result = 3500;
A = s - 3500;
if (A<1500)
{
result += A*0.97;
}
else
{
result += 1500 * 0.97;
if (A<=4500)
{
result += (A - 1500)*0.9;
}
else
{
result += 3000 * 0.9;
if (A<=9000)
{
result += (A - 4500)*0.8;
}
else
{
result += 4500 * 0.8;
if (A<=35000)
{
result += (A - 9000)*0.75;
}
else
{
result += 26000 * 0.75;
if (A<=55000)
{
result += (A - 35000)*0.7;
}
else
{
result += 20000 * 0.7;
if (A<=80000)
{
result += (A - 55000)*0.65;
}
else
{
result += 25000 * 0.65;
result += (A - 80000)*0.55;
}
}
}
}
}
}
}
cout << result;
}