1
#include <iostream>
using namespace std;
int main() {
int greatestToLeastPancakeAmount[10] = {};
int greatestToLeastPersonNumber[10] = {};
int pancakeAmount;
int x;
cout << "Pancake Glutton 1.0 \n\n"; //State program's title
cout << "10 Different people ate pancakes for breakfast.. \n\n";
x = 0;
for(x=0;x<10;x++) {
cout << "How many pancakes did person " << (x + 1) << " eat? > ";
cin >> pancakeAmount;
greatestToLeastPersonNumber[x] = (x + 1);
greatestToLeastPancakeAmount[x] = pancakeAmount;
/*while(pancakeAmount > greatestToLeastPancakeAmount[(x - 1)]) {
int storeGreatestToLeastPancakeAmount = greatestToLeastPancakeAmount[(x-1)];
int storeGreatestToLeastPersonNumber = greatestToLeastPersonNumber[(x-1)];
greatestToLeastPancakeAmount[(x-1)] = pancakeAmount;
greatestToLeastPersonNumber[(x-1)] = x;
greatestToLeastPancakeAmount[x] = storeGreatestToLeastPancakeAmount;
greatestToLeastPersonNumber[x] = storeGreatestToLeastPersonNumber;
}*/
}
cout << "\n\n";
for(x=0;x<10;x++) {
cout << "Person " << greatestToLeastPersonNumber[x] << " ate " << greatestToLeastPancakeAmount[x] << " pancakes!\n";
}
return 0;
}
我该如何完成输出吃煎饼的人最少的人吃的人数?数组和循环:创建一个数字列表最大到最小
有一个'的std :: minmax'算法。 – chris
这就像告诉某人不知道如何钓鱼使用钓鱼竿,并期望他们钓到鱼一样。 – user2877063
那么,参考页面,如[这一个](http://en.cppreference.com/w/cpp/algorithm/minmax)通常包含使用示例以及参数等信息。 – chris