zoukankan      html  css  js  c++  java
  • [CCF] 201612-2 工资计算

     

    【思路】按照题意对初始工资S进行循环,计算缴税后工资,若与T相等则退出循环,输出结果。

     1 #include <iostream>
     2 #include <windows.h>
     3 using namespace std;
     4 int main()
     5 {
     6     int T;
     7     cin>>T;
     8     if(T < 3500)
     9     {
    10         cout<<T<<endl;
    11         return 0;
    12     }
    13     int x = 0;      //扣的钱
    14     int S = 200000; //未缴税的工资
    15     int A = S - 3500;
    16     while(true)
    17     {
    18         if(A <= 1500)
    19             x = A * 0.03;
    20         else if(A <= 4500)
    21             x = 45 + (A - 1500) * 0.1;
    22         else if(A <= 9000)
    23             x = 45 + 300 + (A - 4500) * 0.2;
    24         else if(A <= 35000)
    25             x = 45 + 300 + 900 + (A - 9000) * 0.25;
    26         else if(A <= 55000)
    27             x = 45 + 300 + 900 + 6500 + (A - 35000) * 0.3;
    28         else if(A <= 80000)
    29             x = 45 + 300 + 900 + 6500 + 6000 + (A - 55000) * 0.35;
    30         else
    31             x = 45 + 300 + 900 + 6500 + 6000 + 8750 + (A - 80000) * 0.45;
    32         if(S == x + T)
    33             break;
    34         S = S - 100;
    35         A = S - 3500;
    36     }
    37     cout<<S<<endl;
    38     return 0;
    39 }

  • 相关阅读:
    C++---使用类
    C++---函数
    C++---指针和引用
    C++---面向对象
    C++---数组
    C++---条件结构和循环结构
    C++---变量、数据类型和运算符
    C++---初识C++
    MySQL---什么是事务
    MySQL---char和varchar的区别
  • 原文地址:https://www.cnblogs.com/lca1826/p/6404099.html
Copyright © 2011-2022 走看看