//Pancake Glutton
//Exercise 4 - 4 stars
#include <iostream>
#include <algorithm>
//struct to hold persons
struct Person {
int personNum;
int pancakesEaten;
};
//sort criteria
bool personSorter(const Person &, const Person &);
usingnamespace std;
int main()
{
Person person[10];
int i;
for(i = 0; i<10; ++i)
{
cout << "Enter pancakes eaten by person " << i+1 << ": ";
cin >> person[i].pancakesEaten;
person[i].personNum == i;
}
stable_sort(person, person+10, personSorter);
for(int i = 0; i <10; ++i)
cout << "Person " << person[i].personNum << " ate " << person[i].pancakesEaten << " pancakes " << endl;
return 0;
}
bool personSorter(const Person & lhs, const Person & rhs)
{
if(lhs.pancakesEaten < rhs.pancakesEaten)
returnfalse;
returntrue;
}
Thank you for any help you can offer... i'd appreciate it if you didn't supply me with the proper code but a nudge in the right direction would be great.