Відділ кадрів С++
11

cout<<"(2) Сортировать по стажу \n";

cout<<"(0) Главное меню \n";

 cout<<">: ";

cin>>vib;

switch (vib)

{

  case 1: sort_N1(); break;

  case 2: sort_N2(); break;

  case 0: break;

}

}

 

void createbase(){// процедура створення списку

 thissotr=new(sotrud);

  cout<<"Ф.И.О. сотрудника: "; cin>>thissotr->fio;

  cout<<"Занимаемая должность сотрудника: "; cin>>thissotr->pos;

  cout<<"Возраст сотрудника: "; cin>>thissotr->voz;

  cout<<"Стаж сотрудника: "; cin>>thissotr->stg;

  cout<<"Зарплата сотрудника: "; cin>>thissotr->zar;

  thissotr->next=NULL;

  firstsotr=thissotr;

  firstsotr->next=NULL;

}

 

void openbase(){// відкриття файлу і зчитування записів до списку

int i=0;

FILE *f;

sotrud r;

f=fopen("base.dat","r");

thissotr=new(sotrud);

do{

    fread(&r,sizeof(r),1,f);

    if (i>0) thissotr=thissotr->next;

     strcpy(thissotr->fio,r.fio);

     strcpy(thissotr->pos,r.pos);

     thissotr->voz=r.voz;

     thissotr->stg=r.stg;

     thissotr->zar=r.zar;

    if (i==0){

     firstsotr=thissotr;

     firstsotr->next=nextsotr;

    };

    if (i==1) nextsotr=thissotr;

    i+=1;

    thissotr->next=new(sotrud);

}

while (!feof(f));

thissotr->next=NULL;

thissotr=firstsotr;

fclose(f);

}

 

void savebase(){// запис списку до файлу

 int s;

FILE *f;

sotrud m;

f=fopen("base.dat","w");

thissotr=firstsotr;

while (thissotr !=NULL){

   strcpy(m.fio,thissotr->fio);

   strcpy(m.pos,thissotr->pos);

   m.voz=thissotr->voz;

   m.stg=thissotr->stg;

   m.zar=thissotr->zar;