Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <string.h>
- using namespace std;
- const int nmax=100;
- struct tOrg
- {
- char otdel[30],
- name[20],
- fam[20],
- otch[20];
- int num,
- people;
- };
- int inputmas(tOrg org[], int n)
- {
- while (n<nmax)
- {
- cout<<"Введите название отдела."<<endl;
- cin>>org[n].otdel;
- if (strcmp(org[n].otdel, "end")==0) break;
- cout<<"Введите фамилию начальника отдела"<<endl;
- cin>>org[n].fam;
- cout<<"Введите имя начальника отдела"<<endl;
- cin>>org[n].name;
- cout<<"Введите отчество начальника отдела"<<endl;
- cin>>org[n].otch;
- cout<<"Введите номер кабинета"<<endl;
- cin>>org[n].num;
- cout<<"Введите количество сотрудников в отеде"<<endl;
- cin>>org[n].people;
- n++;
- }
- return n;
- }
- void outputmas (tOrg org[], int k)
- {
- cout<<"Введите количество сотрудников для проверки"<<endl;
- int c;
- cin>>c;
- for (int i=0;i<k;i++)
- {
- if (org[i].people <= c)
- {
- cout<<endl;
- cout<<"Название отдела: "<<org[i].otdel<<endl;
- cout<<"ФИО начальника отдела: "<<org[i].fam<<" "<<org[i].name<<" "<<org[i].otch<<endl;
- cout<<"Кабинет номер "<<org[i].num<<endl;
- cout<<"Количество сотрудников: "<<org[i].people<<endl;
- }
- }
- }
- void orginfo(tOrg org[], int k, char fam1[])
- {
- for (int i=0;i<k;i++)
- {
- if (strcmp(org[i].fam, fam1)==0)
- {
- cout<<endl;
- cout<<"Название отдела: "<<org[i].otdel<<endl;
- cout<<"ФИО начальника отдела: "<<org[i].fam<<" "<<org[i].name<<" "<<org[i].otch<<endl;
- cout<<"Кабинет номер "<<org[i].num<<endl;
- cout<<"Количество сотрудников: "<<org[i].people<<endl;
- }
- }
- }
- void sort(tOrg org[], int k)
- {
- tOrg temp;
- bool fl;
- do
- {
- fl=1;
- for (int i=0;i<k-1;i++)
- if (strcmp(org[i].otdel,org[i+1].otdel)>0)
- {
- temp=org[i];
- org[i]=org[i+1];
- org[i+1]=temp;
- fl=0;
- }
- }
- while (!fl);
- cout<<"Упорядоченые данные:"<<endl;
- for (int l=0;l<k;l++)
- {
- cout<<endl;
- cout<<"Название отдела: "<<org[l].otdel<<endl;
- cout<<"ФИО начальника отдела: "<<org[l].fam<<" "<<org[l].name<<" "<<org[l].otch<<endl;
- cout<<"Кабинет номер "<<org[l].num<<endl;
- cout<<"Количество сотрудников: "<<org[l].people<<endl;
- }
- }
- int main(void)
- {
- setlocale(LC_ALL, "RUSSIAN");
- tOrg org[nmax];
- int n=0,k;
- k=inputmas(org, n);
- outputmas (org, k);
- cout<<"Введите фамилию начальника отдела"<<endl;
- char fam1[20];
- cin>>fam1;
- orginfo (org, k, fam1);
- sort(org, k);
- }
Advertisement
Add Comment
Please, Sign In to add comment