int maxheight(struct nodename* temp)
{
float max;
if (max < temp -> height)
{
temp = temp -> next;
max = temp -> height;
}
return max;
}
void display()
{
nodename *temp = front;
std::cout << "--------------------------" << '\n';
std::cout << " THE TALLEST PERSON IS " << '\n';
std::cout << "--------------------------" << '\n';
std::cout <<"NAME : "<< temp -> name << endl;
std::cout << showpoint << fixed << setprecision(0);
std::cout <<"HEIGHT : " << maxheight(temp) << endl;
std::cout << showpoint << fixed << setprecision(2);
temp = temp -> next;
std::cout << "--------------------------" << '\n';
}
So this is the part where I get confused, the code runs and displays the tallest person's height but not the name as in it displays the name of the first person I have typed and displays the tallest person's height. I cant figure out how to display both the name and the height of the tallest person in the list. I have added the output image for better understanding enter image description here
Aucun commentaire:
Enregistrer un commentaire