我想要數組的元素的平方根,但輸出是錯誤的! 你能幫我糾正我的錯誤嗎? 我如何將數組更改爲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()中的每個元素都放在整個數組指針上 –