水个文
代码如下:
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;const double RATIO = 0.01;
const double SALARY_PER_YEAR = 35;
const double BASE_SALARY = 1000;//
class Employer{
public:int workAge, salary;Employer(){}
};
class Worker:public Employer{double salaryPerHour;int workHour;
public:Worker(int workAge = 0){this->workAge = workAge;}void setSalaryPerHour(double sPH){salaryPerHour = sPH;}void setWorkHour(int wH){workHour = wH;}double getPayPerMonth(void){return salaryPerHour * workHour + workAge * SALARY_PER_YEAR;}
};
class SalesPerson:public Employer{double salaryPerHour, salesAmount;int workHour;
public:SalesPerson(int workAge = 0){this->workAge = workAge;}void setSalaryPerHour(double sPH){salaryPerHour = sPH;}void setWorkHour(int wH){workHour = wH;}void setSalesAmount(double sSA){salesAmount = sSA;}double getPayPerMonth(void){return salaryPerHour * workHour + workAge * SALARY_PER_YEAR + salesAmount * RATIO;}
};
class Manager:public Employer{
public:Manager(int workAge = 0){this->workAge = workAge;}double getPayPerMonth(void){return BASE_SALARY + workAge * SALARY_PER_YEAR;}
};
//int main(){//Person* per = 0;int workAge1,workAge2,workAge3;double salaryPerHour1,salaryPerHour2;int workHour1,workHour2;double salesAmount;cin>>workAge1>>workAge2>>workAge3;cin>>salaryPerHour1>>salaryPerHour2;cin>>workHour1>>workHour2;cin>>salesAmount;Worker* p = new Worker(workAge1);p->setSalaryPerHour(salaryPerHour1);p->setWorkHour(workHour1);cout<<p->getPayPerMonth()<<endl;delete p;SalesPerson* sp = new SalesPerson(workAge2);sp->setSalaryPerHour(salaryPerHour2);sp->setWorkHour(workHour2);sp->setSalesAmount(salesAmount);cout<<sp->getPayPerMonth()<<endl;delete sp;Manager* mgr = new Manager(workAge3);cout<<mgr->getPayPerMonth()<<endl;delete mgr;return 0;
}
一些废话:
两个竞赛都搞完了(如果有进复赛的话,那还有),现在是要忙于转专业了
当然算法学习也是得学的,还得学学Python,C++也得往前超个进度了
我看了一下下一个题,是关于二叉树组成的枚举的,没做过这种,找个时间整整