pancake glutton

I developed a semi working program, the only problem is if the inputs two equal numbers the program bugs out...
Here'es my program
 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283`` ``````#include using namespace std; int pernum=0; int main() { int person [10] = {1,2,4,3,15,17,63,82,19,22}; //random numbers to represent user cin cout << person << endl; int max[11]={100,0,0,0,0,0,0,0,0,0,0}; ////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////* /* for(int a=0; a<10; a++) { if (person[a]> max[0]) { pernum = a; max[0] = person[a]; } } cout << "person" << pernum+1 << "ate " << max[0] << endl; */ /////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////// for (int i=0; i<10; i++) { for(int a=0; a<10; a++) { cout<< a<< ":"<< max[i]<< ":"<< max[i+1] <max[i+1] ) { pernum = a; max[i+1] = person[a]; } } cout << "person" << pernum+1 << "ate " << max[i+1] << endl; } ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// /* for (int x=0; x<10; x++) { for(int y=0; y<10; y++) { if(person[y]>person[y+1]) { buffer1 = person[y+1]; person[y+1] = person[y]; person[y] = buffer1; } } } for(int i=0; i<10; i++) { cout << person[i]; } */ /*int person [5] = {1,2,3,5,6}; for(int i=0; i<5; i++) { cout << person[i]; }*/ return 0; } ``````
Last edited on
closed account (LN7oGNh0)
Is this all of yoour code? Because if it is, then the problem might be caused by not putting the return 0; at the end of the program.
no it's not everything, I have a bunch of comment outs so i copied and pasted the main function, I have return - and including namespace and such.

i tried using <= operator instead of < but that just caused other bugs.
Last edited on
i would say post the whole code, and in code tags, as its a pain to read unindented. And the code you posted is showing 4 opening braces, and 3 closing braces, making it harder to duplicate the problem as we cannot copy and paste your code to try it.
closed account (LN7oGNh0)
I agree with metulburr. Put some code tags in. They are located under the word 'format'.
okay I edited and added the code format wow that looks way better... I pasted the whole code but a lot of it is comments. If you run the code as is it works however, if you change person[10] to have two or more equal values (or the number 0" then it won't show that two people ate the same amount . I was thinking about adding like an OR condition or something but fooling around with it didn't get me much success ><
Last edited on
Topic archived. No new replies allowed.