该指数是我需要解决的方案:返回值最大
编写一个程序,要求用户输入由10个不同的人(
Person 1, Person 2, ..., Person 10
)吃过早餐薄煎饼的数量。
一旦输入数据,程序必须分析数据并输出哪个人吃了早餐最多的煎饼。
任何人可以写返回值最大的指数的代码(我已经标记为 “H”)
#include "iostream"
using namespace std;
int main()
{
int x[11];
int y;
int h;
for (int i = 1; i <= 10; i++)
{
cin >> i[x];
cout << "Person: " << i << " has eaten " << i[x] << " pancakes" << endl
y = x[0];
h = x[0];
for (int j = 1; j <= 10; j++)
{
if (x[j] > y)
{
y = x[j];
}
}
}
cout << "The most pancakes are eaten by Person " << h << " with " << y << endl;
system("pause");
return 0;
}
_'Could anybody write the code for returns the index of maximum value'_ Certainly no!这是**你的**作业! –
这个问题有什么困难?你应该能够在整个互联网上找到资源。 – bblincoe
如何首先使用比x,y和h更具描述性的变量重新标记变量?可以使你的逻辑树更容易工作 – tinkertime