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