void remove(string pick) { student *now = head; if(now !=NULL) { student *picked = head->getNext(); } student *before = head; student *here = NULL; while(now!=NULL) { if(pick == now->getName()) { if(now == head) { here = head; head = here->getNext(); delete here; cout<<"Removal Succesfull"; return; } before = now->getNext(); delete now; cout<<"Removal Sucessful"; return; } before = now; now = now->getNext(); } cout<<"ERROR:Not Found for Removal:"<<pick; };
void abc(){ // this function will alphabatize all the students after adding them int i; for(i = 0;i<(count);i++) { student *now = head; student *next = head->getNext(); // set up pointers to be compared string temp1,temp2; if(now->getNext() == NULL) { return; } else { while(now!= NULL) { temp1 = now->getName(); // set pointers to newly added student temp2 = next->getName(); if(temp1 > temp2) // compare and change { now->setName(temp2); next->setName(temp1); } if(next->getNext() != NULL) { next = next->getNext(); } // keep looping through students to alphabatize now = now->getNext(); } } } };
void search(string find) // this function will search for a student in the linked list based on their name { student *now = head; student *found = head->getNext(); student *before = head; student *here = NULL; while(now != NULL) { if( find == now->getName()) // compare student name to searching name { cout<<"FOUND:"<<""<<now->getName()<<" "<<"UID:"<<now->getID(); return; } else before = now; now= now->getNext(); } cout<<"NOT FOUND:"<<""<<find; };
void search(string find) { student *now = head; student *found = head->getNext(); student *before = head; student *here = NULL; while(now != NULL) { if( find == now->getName()) { cout<<"TRUE:"<<""<<now->getName(); return; } else before = now; now= now->getNext(); } cout<<"FALSE:"<<""<<find; };