Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>//bug
- #include <string>
- #include <fstream>
- #include <vector>
- #include <algorithm>
- #include <iomanip>
- //По дате рождения с помощью сортировки блочной сортировки (Bucket sort).
- using namespace std;
- //В файле содержатся данные о сотрудниках предприятия: ФИО, должность,
- //дата рождения, стаж работы, зарплата (не менее 20 человек). В новый файл вывести
- //данные, отсортированные по какому-либо ключу
- struct worker
- {
- string surname;
- string name;
- string patronymic;
- string position;
- string birth_date;
- string exp;
- string salary;
- string birth_year;
- string birth_month;
- string birth_day;
- };
- void birthTime(vector<worker> &vec)
- {
- for(int i = 0; i < vec.size(); i++)
- {
- vec[i].birth_day = vec[i].birth_date.substr(vec[i].birth_date.length() - 10, 2);
- vec[i].birth_month = vec[i].birth_date.substr(vec[i].birth_date.length() - 7, 2);
- vec[i].birth_year = vec[i].birth_date.substr(vec[i].birth_date.length() - 4, 4);
- }
- }
- void bucketSort(vector<worker> &vec)
- {
- /*int maxValue = 0;
- int minValue = 0;
- for(int i = 1; i < vec.size(); i++)
- {
- if (vec[i] > maxValue)
- maxValue = items[i];
- if (items[i] < minValue)
- minValue = items[i];
- }*/
- }
- int main()
- {
- ifstream in("in.txt");
- ofstream out("out.txt");
- vector<worker> vec;
- while(in.peek() != EOF)
- {
- worker result;
- in >> result.surname >> result.name >> result.patronymic >> result.position >> result.birth_date >> result.exp >> result.salary;
- vec.push_back(result);
- }
- birthTime(vec);
- for(int i = 0; i < vec.size(); i++)
- {
- cout << vec[i].birth_day << " " << vec[i].birth_month << " " << vec[i].birth_year << endl;
- out << left << setw(20) << vec[i].surname << setw(20) << vec[i].name << setw(20) << vec[i].patronymic << setw(20) << vec[i].position << setw(20) << vec[i].birth_date << setw(20) << vec[i].exp << setw(20) << vec[i].salary << endl;
- }
- system("pause");
- }
Add Comment
Please, Sign In to add comment