1 条题解
-
15-何承哲 (938936) LV 9 MOD @ 2020-03-26 21:35:39
题目比较简单,都是以前做过的内容
#include<iostream> #include<vector> #include<iomanip> using namespace std; class Date { friend istream& operator>>(istream& c, Date& x); private: int day, month, year; public: Date(int y=2000,int m=1,int d=1) :year(y),month(m),day(d){} Date(const Date& d):day(d.day),month(d.month),year(d.year){} int getYear() { return year; } int getMonth() { return month; } int getDay() { return day; } }; class Employee { private: Date birthDate; double payr; public: Employee(Date birth = 0 , double basep = 0.0) :birthDate(birth), payr(basep) {} Employee(const Employee& x) :birthDate(x.birthDate), payr(x.payr) {} double getPayroll(int month) { return payr + (month == birthDate.getMonth() ? 100 : 0); } }; istream& operator>>(istream& c, Date& x) { c >> x.year >> x.month >> x.day; return c; } vector<Employee> emp; int main() { int n, i, j; Date tmp; double p; cin >> n; for (i = 0; i < n; i++) { cin >> tmp >> p; emp.push_back(Employee(tmp, p)); } for (j = 1; j <= 12; j++) { for (i = 0; i < n; i++) cout << fixed << setprecision(2) << emp[i].getPayroll(j) << ' '; cout << endl; } }
- 1
信息
- ID
- 1007
- 难度
- 1
- 分类
- (无)
- 标签
- 递交数
- 118
- 已通过
- 36
- 通过率
- 31%
- 上传者