C++Сделать на структурахНа предприятии необходимо хранить данные о работниках: фамилию, имя, отчество, дата рождения, должность, стаж. Вывести на экран данные о тех работников, которые на текущий момент времени достигли 37 лет и имеют стаж не менее 10 лет.
ответы: 1
Зарегистрируйтесь, чтобы добавить ответ
Ответ:
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <ctime>
#include <string>
namespace business {
using namespace std;
struct Date {
int day;
int month;
int year;
Date() = default;
Date(int _day, int _month, int _year) : day(_day), month(_month), year(_year) {}
explicit Date(tm date) {
day = date. tm_mday;
month = date. tm_mon;
year = date. tm_year;
}
~Date() = default;
Date operator- (Date& date) const {
Date diff{};
diff. year = year;
diff. month = month;
diff. day = day;
diff. day -= date. day;
if (diff. day <= 0) {
diff. day = 31 - diff. day;
diff. month -= 1;
}
diff. month -= date. month;
if (diff. month <= 0) {
diff. month = 12 - diff. month;
diff. year -= 1;
}
diff. year -= date. year;
return diff;
}
};
struct Worker {
string fio;
Date birthday{};
string job;
int stage{};
Worker() = default;
Worker(string fio, Date birthday, string job, int stage){