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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <iostream>

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] <<endl;
	  
	  	
	     if (person[a]< max[i] && person[a]>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.