Help anyone?

I was searching for an exercise and was wondering how am I gonna do this?

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

This is my code...

#include <iostream>
#include <fstream>
#include <string>
#include <conio.h>

using namespace std;

string names[10]={};
int numberOfPancakesEaten[10]={};

void pancakesEaten(){
cout << "Hello! Please enter 10 persons with how many pancakes they've eaten for breakfast." << endl;
cout << "Name Pancakes\n" << endl;

for(int i=0;i<10;i++){
cin >> names >> numberOfPancakesEaten;
}

for(int x=0;x<10;i++){
names, numberOfPancakesEaten;
}
cout << "The number of most eaten pancakes are ", numberOfPancakesEaten.max() << endl;
}


////////////////////////////////main////////////////////////////
int main(){
pancakesEaten();

}

I know it's kinda far away from finishing it but can u guys tell me what i can do? Thanks guys! ;)









Unfortunately, plain C arrays don't have built-in methods like max(), min(), etc. One approach would be to actually determine the max/min values as you process the user's input. Another way is to use std::vector, then sort it using std::sort.
plain C arrays don't have built-in methods like max(), min()

No, but there is std::begin(), std::end() which can return iterators to the beginning and end of arrays:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <algorithm>

int main()
{
	int arr [] = {3, 7, 1, 34, 0, 9};
	
	std::cout<< "Unsorted data\n";
	for (auto i: arr) std::cout<< i<< ' ';
	std::cout<< '\n';
	
	std::sort(std::begin(arr), std::end(arr), [] (int a, int b) { return a <= b; });
	
	std::cout<< "Sorted data\n";
	for (auto i: arr) std::cout<< i<< ' ';
	std::cout<< '\n';
	
	return 0;
}
Unsorted data
3 7 1 34 0 9 
Sorted data
0 1 3 7 9 34 
Topic archived. No new replies allowed.