Ok so i'm working on a task which i stumbled onto from some earlier days of this site (2008 or something like that) and it doesnt allow to reply anymore, so i was wondering... If you are supposed to make a list of persons, and the user inputs a number onto every person, how do i make this list to be arranged from highest to lowest? I'm not really understanding arrays yet, and while seartching and looking around, i couldnt find anything that i honestly understood x)
Sooo im asking you guys ;*
- friendly regards Kristofferkh
Heres the task:
________________________________________________________________________________
Pancake Glutton
Requires:
variables, data types, and numerical operators
basic input/output
logic (if statements, switch statements)
loops (for, while, do-while)
arrays
Write a program that asks the user to enter the number of pancakes eaten for breakfast by 10 different people (Person 1, Person 2, ..., Person 10)
Once the data has been entered the program must analyze the data and output which person ate the most pancakes for breakfast.
★ Modify the program so that it also outputs which person ate the least number of pancakes for breakfast.
★★★★ Modify the program so that it outputs a list in order of number of pancakes eaten of all 10 people.
i.e.
Person 4: ate 10 pancakes
Person 3: ate 7 pancakes
Person 8: ate 4 pancakes
...
Person 5: ate 0 pancakes
Ah yeh. Ive done this one. Yep, you gotta create an integer array for 10 people and 10 breakfasts. Then do a function which determines the most pancakes eaten.
ok so ive done this, but i cant get it to make a list. I dont understand all of it, some of it is taken from research. But this is as far as ive gotten
int main(){
long int i,minimum,maximum, contestants[10]; //Integers n shit
cout << "You have entered a pancake eating contest, as a spectator.\n"
<< "You are asked by a reporter to say how many pancakes each contester ate\n";
for(i=0;i<=9;){
cout << "Contestant number " << i << " ate: ";
cin >> contestants[i]; // Loop for getting the answer to each person.
i++; // Not sure how to get every contestants answer without the 0.....
}
minimum = contestants[1];
maximum = contestants[i];
for(i=2;i<=9;){
if(minimum>contestants[i])
minimum = contestants[i];
if(maximum<contestants[i])
maximum = contestants[i];
i++;
}
for(i=0;i<=9;){
if(minimum==contestants[i])
cout << "\nContestant number " << i << " Ate the least pancakes....(" << minimum <<")";
if(maximum==contestants[i])
cout << "\nContestant number " << i << " Ate the most pancakes!! (" << maximum << ")";
i++;
}