我想要数组的元素的平方根,但输出是错误的! 你能帮我纠正我的错误吗? 我如何将数组更改为100?阵列函数错误输出
#include <math.h>
#include <iostream>
using namespace std;
// function declaration:
double sqrootx(int arr[], int size);
int main()
{
// an int array with 5 elements.
double balance[5] = {1000, 2, 3, 17, 50};
double sqr;
// pass pointer to the array as an argument.
sqr= pow(balance, 5) ;
// output the returned value
cout << " result" << sqr << endl;
return 0;
}
你的代码真的没有任何意义。我们也不知道你想要做什么或者你期望的输出。例如,函数'sqrootx'应该用它的平方根替换数组中的每个条目?如果是这样,为什么它会返回一个'double'? –
我想知道阵列的功率应该输出什么......? – shift66
你必须把pow()中的每个元素都放在整个数组指针上 –