Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include "iostream"
- #include "stdio.h"
- using namespace std;
- struct Info {
- char Surname[20];
- int Salary;
- int BirthYear;
- };
- class Sotr {
- Info* mass;
- int N;
- public:
- void Input();
- double Sr_Num();
- void Write_FL();
- };
- void Sotr::Input() {
- cout << "Введите количество сотрудников" << endl;
- cin >> N;
- mass = (Info*)malloc(N * sizeof(Info));
- for (int i = 0; i < N; i++)
- {
- cout << "Введите имя сотрудника" << endl;
- cin >> mass[i].Surname;
- cout << "Введите зп сотрудника" << endl;
- cin >> mass[i].Salary;
- cout << "Введите год рождения сотрудника" << endl;
- cin >> mass[i].BirthYear;
- }
- }
- double Sotr::Sr_Num() {
- int Summ = 0;
- for(int i=0; i<N; i++)
- {
- Summ += mass[i].Salary;
- }
- return Summ / N;
- }
- void Sotr::Write_FL() {
- FILE* f;
- fopen_s(&f, "Tovar.txt", "wt");
- fprintf(f, "%-20s", "Name");
- fprintf(f, "%-12s", "Salary");
- fprintf(f, "%-12s", "Birth");
- fprintf(f, "%-12s", "Age");
- fprintf(f, "\n");
- for (int i = 0; i < N; i++)
- {
- if (mass[i].Salary > Sr_Num())
- {
- fprintf(f, "%-20s", mass[i].Surname);
- fprintf(f, "%-12d", mass[i].Salary);
- fprintf(f, "%-12d", mass[i].BirthYear);
- fprintf(f, "%-12d", 2019 - mass[i].BirthYear);
- fprintf(f, "\n");
- }
- }
- fclose(f);
- cout << "Произведена запись в файл";
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- Sotr q;
- q.Input();
- q.Sr_Num();
- q.Write_FL();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement