Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- struct rezume{
- char name[30];
- int age;
- int study;
- int kitchen[4];
- int experience;
- int max_experience_one_place;
- int number_change_work;
- int dismiss_from_kitchen;
- };
- int main() {
- ifstream input("C:\\Users\\ilgam\\CLionProjects\\exam_task_1\\rezume");
- rezume applicants;
- auto *chef = new rezume[100];
- int n;
- cout<<"enter number applicants n = ";
- cin>>n;
- cout<<endl;
- if(!input){
- cout<<"Can't open file";
- exit(-1);
- }
- int i=0;
- while( input>>applicants.name>>applicants.age>>applicants.study>>applicants.kitchen[0]>>applicants.kitchen[1]
- >>applicants.kitchen[2]>>applicants.kitchen[3]>>applicants.experience>>applicants.max_experience_one_place
- >>applicants.number_change_work>>applicants.dismiss_from_kitchen) {
- if((applicants.age<50)&&(applicants.study==1||applicants.study==2)&&(applicants.kitchen[0]==1||applicants.kitchen[1]==1)
- &&(applicants.experience>=5)&&(applicants.max_experience_one_place*2>=applicants.experience)&&(applicants.number_change_work<=5)
- &&(applicants.dismiss_from_kitchen<=1)){
- chef[i]=applicants;
- i++;
- }
- }
- for (int j=0; j < i; j++) {
- for (int k=j+1; k < i; k++) {
- if (chef[j].experience < chef[k].experience) {
- applicants = chef[j];
- chef[j] = chef[k];
- chef[k] = applicants;
- }
- }
- }
- if (i < n) {
- cout << "Pretendents less necessory!";
- exit(1);
- }
- ofstream bin_output("C:\\Users\\ilgam\\CLionProjects\\exam_task_1\\rezume.bin", ios::out|ios::binary);
- for(i=0;i<n;i++) {
- bin_output.write((char *) &chef[i], sizeof(struct rezume));
- }
- bin_output.close();
- bool p = false;
- //auto *chef_top= new rezume[10];
- ifstream bin_input("C:\\Users\\ilgam\\CLionProjects\\exam_task_1\\rezume.bin", ios::in|ios::binary);
- for (int i = 0; i <n ; ++i) {
- bin_input.read((char *) &chef[i], sizeof(struct rezume));
- }
- for (i = 0; i < n; i++) { //
- if ((chef[i].age <= 45) && (chef[i].study == 2) && (chef[i].experience >= 15) &&
- (chef[i].dismiss_from_kitchen == 0) && (chef[i].number_change_work <= 2)) {
- p = true;
- cout << chef[i].name << ' ' << chef[i].age <<' ' << endl;
- }
- }
- bin_input.close();
- if (!p){
- cout << "Sorry! Chief cook is not appeared!" << endl; //
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement