Hello, I have been coding with c++ for about 2-3 weeks now and I have been stuck with one exercise called "Pancake glutton" I need to collect answers from 10 people how many pancakes have they ate for breakfast and output answers in order with their respective number like that:
Person 4: ate 10 pancakes
Person 3: ate 7 pancakes
Person 8: ate 4 pancakes
...
Person 5: ate 0 pancakes
I have found a way how to put out the pancake amounts in decreasing order, but I still need to find out how to associate pancake amount with persons number.
#include<iostream>
usingnamespace std;
int main(){
int amount[10], number;
for(number=0;number<=9;number++){
cout<<"How many pancakes does person # "<<number+1<<" ate?"<<endl;
cin>>amount[number];
}
for(int a=0;a<=8;a++){
int temp;
for(int b=a+1;b<=9;b++){
if(amount[a]>amount[b]){
temp=amount[a];
amount[a]=amount[b];
amount[b]=temp;
}
}
}
cout<<endl;
for(int c=0;c<=9;c++){
cout<<amount[c]<<" pancakes"<<endl; //I need to find a way to somehow tie pancake amount and persons number together
}
}