Hey. I'm trying to write a practice program that takes 10 numbers of the number of pancakes a person eats. The program works up until the output of the min and max numbers. It will output the following
The skinniest person here is person #0 from eating only 10 pancakes!
every time...
Here's the code. I created a 2x10 array. 1 row containing the persons number and the other containing the number of pancakes. the way the HighEater and LowEater functions are supposed to work is that they traverse the array. If the current coor.'s value is greater/lesser than the min/max, it will assign the Max/Min value whatever the current number is...
#include <iostream>
usingnamespace std;
int xEnd = 10;
int pancakes[2][10];
void HighEater();
// Finds the biggest glutton
void LowEater();
// Finds who ate the least.
void Test();
//tests the array
int main()
{
for (int i = 0; i++ < xEnd;) pancakes[0][i]=i; //sets up array row 1
cout << please enter the amount of pancakes ten people ate individually!"\n";
for (int i = 0; i++< xEnd;) {
cin >> pancakes[1][i]; // sets up array row 2
}
HighEater();
LowEater();
return 0;
}
void Test() {
for (int y = 0; y < 2;y++) {
for (int x = 0; x++ < xEnd;)
cout << pancakes[y][x] << "\t";
cout << "\n";
}
}
void HighEater()
{
int MAX = 0;
for (int i = 0; i < xEnd; i++) {
if (pancakes[1][i] > pancakes[1][MAX]) MAX = pancakes[0][i];
}
cout << "The biggest glutton in the group is person #" << pancakes[0][MAX] << " with "<< pancakes[1][MAX]<< " pancakes!"<<endl;
}
void LowEater() {
int MIN = pancakes[0][0];
for (int i = 0; i < xEnd; i++) {
if (pancakes[1][i] <=pancakes[1][MIN])
MIN = pancakes[0][i];
}
cout << "The skinniest person here is person #" << pancakes[0][MIN] << " from eating only "<< pancakes[1][MIN]<< " pancakes!"<<endl;
}