Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <conio.h>
- #include <clocale>
- using namespace std;
- struct employee {
- string surname;
- string department_name;
- int year_of_birth;
- string speciality;
- int experience;
- int salary;
- };
- void show_sorted_by_experience( employee employees [], int n ) {
- int changes = 1;
- employee temp_employee;
- while ( changes != 0 ) {
- for ( int i = 0; i < n; i++ ) {
- changes = 0;
- for ( int j = i + 1; j < n; j++ ) {
- if ( employees[i].experience > employees[j].experience ) {
- temp_employee = employees[i];
- employees[i] = employees[j];
- employees[j] = temp_employee;
- changes++;
- }
- }
- }
- }
- cout << "Отсортированный массив работников по возрастанию стажа: " << endl;
- for ( int i = 0; i < n; i++ ) {
- cout << "Фамилия: " << employees[i].surname << "; Название отдела: " << employees[i].department_name << "; Год рождения: " << employees[i].year_of_birth << "; Стаж работы: " << employees[i].experience << "; Должность: " << employees[i].speciality << "; Оклад: " << employees[i].salary << endl;
- }
- }
- void show_by_experience( employee employees [], int n, int X) {
- cout << "Работники со стажем больше " << X << " лет. " << endl;
- for ( int i = 0; i < n; i++ ) {
- if ( employees[i].experience > X ) {
- cout << "Фамилия: " << employees[i].surname << "; Название отдела: " << employees[i].department_name << "; Год рождения: " << employees[i].year_of_birth << "; Стаж работы: " << employees[i].experience << "; Должность: " << employees[i].speciality << "; Оклад: " << employees[i].salary << endl;
- }
- }
- }
- int main( )
- {
- setlocale( LC_ALL, "Russian" );
- const int n = 4;
- employee arr[n] = {
- "asdasd", "dsa", 1989, "asdads", 6, 539254,
- "dsadida", "dsad", 1990, "dsadsa", 2, 23923,
- "dsadas", "sda", 1991, "asdfs", 10, 202222,
- "dsadsadsa", "a", 1909, "dsa", 1, 200220
- };
- show_sorted_by_experience( arr, n );
- cout << endl << endl;
- show_by_experience( arr, n, 4 );
- _getch( );
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement