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
|
#include <iostream>
using namespace std;
int main()
{
int person[10]={1,2,3,4,5,6,7,8,9,10};
int number[10];
int temp = 0;
int value = 0;
int index = 0;
for (int i = 0; i < 10; i++)
{
cout << "Enter the number of pancakes eaten by person "
<< person[i] << "." << endl;
cin >> number[i];
}
for(int i=0;i<10;i++)
{
if(number[i]>temp){
temp=number[i];
index = i;
}
}
cout << "The person that ate the most pancakes for breakfast is person "
<< person[index] << " who ate " << temp << " pancakes."
<< endl;
return 0;
}
|
Enter the number of pancakes eaten by person 1.
1
Enter the number of pancakes eaten by person 2.
2
Enter the number of pancakes eaten by person 3.
3
Enter the number of pancakes eaten by person 4.
4
Enter the number of pancakes eaten by person 5.
50
Enter the number of pancakes eaten by person 6.
6
Enter the number of pancakes eaten by person 7.
7
Enter the number of pancakes eaten by person 8.
8
Enter the number of pancakes eaten by person 9.
9
Enter the number of pancakes eaten by person 10.
10
The person that ate the most pancakes for breakfast is person 5 who ate 50 pancakes. |