![]() |
| ||
| Looking up and displaying values in linked lists Hi everybody, I am currently working on an assignment on linked lists. I am stuck with parts of the project, and I would be very pleased if anyone could help me. I am supposed to create a linked list of patient records. Each record is identified by a patient ID and contains patient name, age, and also blood glucose level. All of this is given via input from the user. I have one main problem: In this assignment, there should be functions for finding the highest and lowest age of the patients entered. I can find the max and min ages - this works - BUT after having done that, the patient record for that particular patient need to be displayed, and this is where I get problems! How can I use the value of the new "max" to lookup the patient that has the maximum age? I have tried different ways of assigning max to temp->age and then trying to find ID - it does not give me any errors at compilation but it breaks down when I run the program. NB I have omitted some of the functions in the code. #include <iostream> and in main: int main() Thanks for your help, Gro |
| ||
| Re: Looking up and displaying values in linked lists You could create additional pointers to the linked list that you assign during the search functions (Pass the pointers as parameters). Then, once you've searched, you can continue to bring up information from those particular patients through the pointers which are still referencing to the same area in memory. Or, you could make your max function return the offset from the head of the list. So, when you want to look at that patient's info, you iterate through the list in a loop, then retrieve the appropriate information. |
| ||
| Re: Looking up and displaying values in linked lists What would happen if you ran this code? void List::ListMax() |
| ||
| Re: Looking up and displaying values in linked lists Thanks for your very rapid answers! I will try to implement it in the code and make it work. Thank you Gro |
| All times are GMT -4. The time now is 7:57 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC