c++ - How to compare the value inside of an array -


so im writing program asks user input number of pancakes person(1-10) had breakfast. program must analyze input , determine person ate pancakes. program must output list in order of number of pancakes eaten of 10 people. far have written code user input , code display array, not in order. im lost when comes comparing elements in array:

int getpancakes(); void displayarray(int thearray[],int sizeofarray); void comparearray(int sizeofarray); int pancakes[10]; int z = 0;  int main() { }  int getpancakes(){     int y;     int x = 0;      for(int y = 0; y < 10; y++){         ++x;         cout << "how many pancakes did person " << x << " eat?" << endl;         cin >> pancakes[y];     } }  void displayarray(int thearray[],int sizeofarray){     for(int x = 0 ;x < sizeofarray ; x++){         ++z;         cout << "person " << z << " ate " << pancakes[x] << " pancakes" << endl;     } } 

so how can instruct program compare elements inside array? how can instruct program print list of number of pancakes eaten each person in order?

if numbers unique

int max = 0; for(int x = 0 ;x < 10 ; x++) {     if(pancakes[x] > max)         max = pancakes[x]; } for(int x = 0 ;x < 10 ; x++) {     if(pancakes[x] == max)          cout << "person " << x << " ate " << pancakes[x] << " pancakes - biggest number" << endl; } 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -