gpt4 book ai didi

c++ - double 类型的参数与参数类型双指针不兼容

转载 作者:行者123 更新时间:2023-11-28 07:18:27 25 4
gpt4 key购买 nike

试图找到最低分和最高分,但我一直出错

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com