#include <iostream> // write your code here...... #include <vector> #include <algorithm> #include <iomanip> using namespace std; class Employee { private: string name; double salary; // write your code here...... public: Employee(string name, double salary) { this->name = name; this->salary = salary; } string getName() { return this->name; } double getSalary() { return this->salary; } double getTax() { int base = this->salary - 3500; int tax = 0; if (base <= 1500) tax = base * 0.03; else if (base > 1500 && base <= 4500) tax = base * 0.1 - 105; else if (base > 4500 && base <= 9000) tax = base * 0.2 - 555; else if (base > 9000 && base <= 35000) tax = base * 0.25 - 1005; else if (base > 35000 && base <= 55000) tax = base * 0.3 - 2755; else if (base > 55000 && base <= 80000) tax = base * 0.35 - 5505; else tax = base * 0.45 - 13505; return tax; } }; bool cmp(Employee &e1, Employee &e2) { return e1.getSalary() > e2.getSalary(); } int main() { // write your code here...... Employee e1("张三", 6500); Employee e2("李四", 8000); Employee e3("王五", 100000); vector<Employee> v; v.push_back(e1); v.push_back(e2); v.push_back(e3); sort(v.begin(), v.end(), cmp); for (auto it = v.begin(); it != v.end(); it++) { cout << it->getName() << "应该缴纳的个人所得税是:" << fixed << setprecision(1) << it->getTax() << endl; } return 0; }