试图找到最低分和最高分,但我一直出错
argument of type "double" is incompatible with parameter of type "double*"
代码:
cout << "The lowest of the results = " << find_lowest(score[5]);
cout << "The highest of the results = " << find_highest(score[5]);
system("Pause");
}
double find_highest(double a[])
{
double temp = 0;
for(int i=0;i<5;i++)
{
if(a[i]>temp)
temp=a[i];
}
return temp;
}
double find_lowest(double a[])
{
double temp = 100;
for(int i=0;i<5;i++)
{
if(a[i]<temp)
temp=a[i];
}
return temp;
}
最佳答案
正如@jogojapan 指出的那样,您将不得不更改这些
cout << "The lowest of the results = " << find_lowest(score[5]);
cout << "The highest of the results = " << find_highest(score[5]);
到
cout << "The lowest of the results = " << find_lowest(score);
cout << "The highest of the results = " << find_highest(score);
您的函数需要 double 组,而不是 double 元素。
关于c++ - double 类型的参数与参数类型双指针不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19887026/