Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.4 kB
2
Indexable
Never
#include <iostream>
#include <Windows.h>
using namespace std;

struct workman
{
    string surname;
    int age = 0;
    int work_exp = 0;
    int years_to_pens = 0;
};

void GetData(workman* list, int n)
{
    for (int i = 0; i < n; i++)
    {
        cout << "Введите фамилию" << endl;
        cin >> list[i].surname;
        cout << "Введите возраст" << endl;
        cin >> list[i].age;
        cout << "Введите стаж" << endl;
        cin >> list[i].work_exp;
        cout << "Введите кол-во лет до пенсии" << endl;
        cin >> list[i].years_to_pens;
    }

}

void ShowData(workman* list, int n)
{
    cout << "\n" << "Фамилия" << "\t" 
         << "Возраст" << "\t" 
         << "Стаж" << "\t" 
         << "Лет-до-пенсии" << endl;
    for (int i = 0; i < n; i++)
    {
        if (list[i].years_to_pens < 15)
            cout << list[i].surname << "\t"
            << list[i].age << "\t"
            << list[i].work_exp << "\t"
            << list[i].years_to_pens << endl;
    }

}

int main()
{
    SetConsoleCP(1251);
    setlocale(LC_ALL, "Russian");

    int n;
    cout << "Введите количество рабочих" << endl;
    cin >> n;
    
    workman* list = new workman[n];
    GetData(list, n);
    ShowData(list, n);
    delete[]list;
}