codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <iostream> int main() { using namespace std; int NumofPan[10]; int OrderofPan[10]; int PersonNum[10]; int pmax; int i = 0; int j = 0; cout << "All pancake values must be greater than 0\n"; for (i = 0; i < 10; i++) { cout << "How many Pancakes did person " << ++i << " eat?\n"; cout << "Number of Pancakes: "; --i; cin >> NumofPan[i]; while (NumofPan[i] < 1) { cout << "All pancake values must be greater than 0\n"; cout << "How many Pancakes did person " << ++i << " eat?\n"; cout << "Number of Pancakes: "; --i; cin >> NumofPan[i]; } cout << endl; } pmax = 0; for (j = 0; j < 10; j++) { for (i = 0; i < 10; i++) { if (pmax < NumofPan[i] && NumofPan[i] > 0) { pmax = NumofPan[i]; PersonNum[j] = i; OrderofPan[j] = NumofPan[i]; } } i = PersonNum[j]; NumofPan[i] = 0; pmax = 0; } for (i = 0; i < 10; i++) cout << "Person\t" << ++PersonNum[i] << " ate \t" << OrderofPan[i] << " pancakes\n"; cout << "\nPress ENTER to exit\n"; cin.get(); cin.get(); return 0; }
Private
[
?
]
Run code
Submit