/* http://pnu.hamidjalali.com www.8gerd.tk */ #include #include #include #include class studentrecord { public: studentrecord(); char fname[10]; char lname[10]; int ID; char programme[10]; int year_of_study; studentrecord *nxt; void register_student(); void display_all(); void displayStudentInformation(); void Swap(); void SearchStudent(); void DeleteStudent(); void ConditionalDisplay(); }; studentrecord::studentrecord() { } studentrecord *start_ptr=NULL; int khetho=0; void studentrecord::register_student() { studentrecord *temp,*temp2; temp=new studentrecord; cout<<"enter the student fist name:"<>temp->fname; cout<<"enter student last name:"<>temp->lname; cout<<"enter student id:"<>temp->ID; cout<<"Enter the Programme of the student:"<>temp->programme; cout<<"Enter student's year:"<>temp->year_of_study; temp->nxt=NULL; if(start_ptr==NULL) { start_ptr=temp; } else { temp2=start_ptr; while(temp2->nxt!=NULL) { temp2=temp2->nxt; } temp2->nxt=temp; } } void studentrecord::display_all() { studentrecord *temp; temp=start_ptr; if(start_ptr==NULL) { cout<<"the record is empty"<lname<ID<fname<programme<nxt; } } } void studentrecord::Swap() { studentrecord *temp,*temp2,*temp3,*temp4; temp= start_ptr; cout<>id; cout<<"enter 2nd ID u want to swap "<>id1; if (start_ptr == NULL) { cout << "The list is empty!" << endl; } while(temp!=NULL) { if(temp->ID=id1) { temp2=temp; temp=temp->nxt; } } while(temp3!=NULL) { if(temp3->ID=id1) { temp4=temp3; temp3=temp3->nxt; } } temp->nxt=temp4; temp3->nxt=temp2; temp->nxt=temp3->nxt; temp3->nxt=temp->nxt; //temp4->nxt=temp2->nxt; //temp2->nxt=temp4->nxt; //temp3->nxt=temp2; // temp2->nxt=temp->nxt; // delete temp; cout<>id; if (start_ptr == NULL) cout << "The list is empty!" << endl; else { while(temp!=NULL ) { if(temp->ID==id) { cout<<"ID :"<ID<fname<lname<programme<year_of_study<display_list(); temp = temp->nxt; } cout<>id; if (start_ptr == NULL) { cout << "The list is empty!" << endl; } if(start_ptr->ID = id) { temp=start_ptr; start_ptr=start_ptr->nxt; delete temp; } else { while(temp->ID!=id) { temp2=temp; cout<ID; count++; temp = temp->nxt; } temp2->nxt=temp->nxt; delete temp; cout<>lastname; if (temp == NULL) cout << "The list is empty!" << endl; else { while(temp!=NULL ) { if(temp->lname==lastname) { cout<lname<fname<ID<ID<year_of_study<nxt; } //temp->display_list(); temp = temp->nxt; } cout<>id; if (temp == NULL) cout << "The list is empty!" << endl; else { while(temp!=NULL ) { if(temp->ID==id) { cout<fname<lname<ID<year_of_study<display_list(); temp = temp->nxt; } cout<> khetho; switch (khetho) { case 1 : l.register_student(); cout<<" ";system("pause"); system("cls"); break; case 2 : l.SearchStudent(); break; case 3 : l.Swap(); break; case 4 : l.displayStudentInformation(); break; case 5 : l.display_all();break; case 6 : l.ConditionalDisplay();break; case 7 : l.DeleteStudent();break; } } while (khetho != 0); }