[ create a new paste ] login | about

Link: http://codepad.org/sGA1udX5    [ raw code | fork | 1 comment ]

MottMan - C++, pasted on Jul 11:
#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;
}


Create a new paste based on this one


Comments:
posted by MottMan on Jul 14
Could've just used i+1 as it does not change the variable but the output.
reply