Написать программу согласно заданию.
Поля структуры:
Фамилия
Имя
Отчество
Должность
Зарплата
Дата рождения
Задача:
Вывести сведения о сотрудниках, которые родились в мае.
C/C++
Помогите решить задачу C++, пожалуйста.
#include
#include
#include
using namespace std;
template
T input(istream& inp, const char* msg) {
cout > value;
inp.ignore(0x1000, '\n');
return value;
}
struct Date {
int day;
int month;
int year;
Date() : day(30), month(12), year(1922) {}
string tostring()const {
static const auto ten = 10;
string date;
if (day < ten) date += '0';
date += to_string(day) + '.';
if (month < ten) date += '0';
date += to_string(month) + '.' + to_string(year);
return date;
}
private:
friend istream& operator>>(istream& inp, Date& date) {
date.year = input(inp, "Введите год даты рождения: ");
date.month = input(inp, "Введите месяц даты рождения: ");
date.day = input(inp, "Введите день даты рождения: ");
return inp;
}
friend ostream& operator> person.date_of_birth;
return inp;
}
friend ostream& operator employee.person;
cout
#include <iostream>
#include <string>
#include <vector>
struct Employee
{
std::string surname;
std::string name;
std::string middle_name;
std::string job_title;
double salary;
std::string date_of_birth;
};
int main()
{
std::vector<Employee> employees;
// populate the vector with Employee objects
std::cout << "Employees born in May:" << std::endl;
for (const Employee& employee : employees)
{
if ( employee.date _of_birth.find("May") != std::string::npos)
{
std::cout << employee.surname << " " << employee.name << " " << employee.middle_name << std::endl;
std::cout << "Job title: " << employee.job_title << std::endl;
std::cout << "Salary: " << employee.salary << std::endl;
std::cout << "Date of birth: " << employee.date _of_birth << std::endl;
std::cout << std::endl;
}
}
return 0;
}
#include <string>
#include <vector>
struct Employee
{
std::string surname;
std::string name;
std::string middle_name;
std::string job_title;
double salary;
std::string date_of_birth;
};
int main()
{
std::vector<Employee> employees;
// populate the vector with Employee objects
std::cout << "Employees born in May:" << std::endl;
for (const Employee& employee : employees)
{
if ( employee.date _of_birth.find("May") != std::string::npos)
{
std::cout << employee.surname << " " << employee.name << " " << employee.middle_name << std::endl;
std::cout << "Job title: " << employee.job_title << std::endl;
std::cout << "Salary: " << employee.salary << std::endl;
std::cout << "Date of birth: " << employee.date _of_birth << std::endl;
std::cout << std::endl;
}
}
return 0;
}
Похожие вопросы
- Помогите решить задачу, c++, функции
- Помогите решить задачу C++
- Помогите решить задачу c++
- Пожалуйста, помогите решить задачу! C++
- Помогите решить задачу C++
- Помогите решить задачу C++
- Помогите решить задачу C++
- Помогите решить задачу . C++
- Помогите решить задачу пожалуйста, в C++
- Помогите решить задачу по программированию на C++