Разработка программы для создания и обработки вакансий в виде двусвязного списка, страница 3

13. void out_of_display(Vacancy* begin)

Рис. 2.13


14. void save_list (Vacancy *begin, char * spisok)

Рис. 2.14


15. void open_new_list (Tpublishing_firm* &end, Tpublishing_firm* &begin, char * name_file)

Рис. 2.15

16. void open_add_list (Vacancy* &end, Vacancy* &begin, char *name_file)

Рис. 2.16

17. int swap_element(Vacancy* Worker1, Vacancy* &end, Vacancy* &begin)

Рис. 2.17

18. void orend_of_city(Vacancy* &end, Vacancy* &begin)

Рис. 2.18


19. void general_menu (Vacancy* &begin, Vacancy* &end)

Рис. 2.19


3. ЛИСТИНГ ПРОГРАММЫ

#include <iostream.h>

#include <fstream.h>

#include <string.h>

#include <conio.h>

#include <stdlib.h>

struct address

{ char*city;

char*street;

int house;

};

struct conditions_work

{int min_wages;

int holidays;

int nominal_hours;

};

struct demand

{ char*education;

char*profession;

int total_period;

int length_service;

};

struct Vacancy

{ char* name;

address*firm;

char*post;

conditions_work*offer;

demand*expert;

Vacancy*next;

Vacancy*previous; };

ostream& operator << (ostream& out, Vacancy* Worker)

{

out << "firm:"<<Worker->name <<" "<< Worker-> firm->city  <<" "<<Worker-> firm->street <<" "<<Worker-> firm->house  <<endl

    <<"doljnost':"<<Worker->post<<" "<<Worker-> offer->min_wages  <<" "<<Worker-> offer-> holidays <<" "<<Worker-> offer->nominal_hours <<endl

    <<"trebovaniya:"<<" obrazoanie:"<<Worker-> expert -> education <<" professiya:"<<Worker-> expert -> profession <<" obsh'i staj:"<<Worker-> expert->total_period <<"  staj po doljnosti:"<<Worker-> expert->length_service <<endl;

    return out;

}

istream& operator >> (istream& in, Vacancy *Worker)

{

char *str=new char [30];

 cout << "name:";

 in >> str;

Worker->name=strdup(str);

Worker->firm=new address;

 cout << "city:";

 in >> str;

 Worker-> firm->city  =strdup(str);

 cout << "street:";

in >> str;

 Worker-> firm->street  =strdup(str);

 cout << "house:";

 in >> Worker-> firm->house ;

 cout << "doljnost':";

 in >> str;

 Worker-> post =strdup(str);

Worker->offer=new conditions_work;

 cout << "z/p:";

 in >> Worker-> offer->min_wages ;

cout << "holidays:";

 in >> Worker-> offer->holidays ;

cout << "vremya:";

 in >> Worker-> offer->nominal_hours ;

Worker-> expert =new demand;

  cout << "obrazovanie:";

 in >> str;

 Worker-> expert -> education =strdup(str);

 cout << "professiya:";

 in >> str;

 Worker-> expert -> profession =strdup(str);

 cout << " obsh'i staj:";

 in >>Worker-> expert->total_period;

 cout << " staj po doljnosti:";

 in >>Worker-> expert-> length_service;

 delete []str;

return in;

}

Vacancy* input_new (Vacancy* &Worker)

 {

 Vacancy *work=Worker;

 Worker=new Vacancy;

 if (Worker==NULL) { Worker=work;

                      return NULL;

                     }

 cin >> Worker;

 if (work==NULL) Worker->previous=NULL;

           else   { Worker->previous=work;

                      work->next=Worker;

                     }

 Worker->next=NULL;

 return Worker;

 }

Vacancy* delete_element (Vacancy* &Worker, Vacancy* &begin)

 {

 Vacancy *work;

 if ((Worker->previous==NULL)&&(Worker->next==NULL))

                                begin=NULL;

 if ((Worker->previous==NULL)&&(begin!=NULL))

                             { begin=Worker->next;