0
我正在写一个函数来返回数组的总和,但是我的测试用例显示没有来自该特定函数的输出。任何人都可以帮忙使用指针返回数组的总和 - 无输出
double sumArray(int n, double * array) {
// Add your code here
int i;
double sum = 0.000000;
double *ptr;
ptr = array;
if (n == 0) {
return 0.000000;
} else {
for (i = 0; i < n; i++) {
sum = sum + *ptr;
ptr++;
}
return sum;
}
}
你应该在哪里看到输出? – Goodies
[无法重现](http://melpon.org/wandbox/permlink/8Y18UimLE3e0TmCW)。请发布具有所需行为的[最小,完整和可验证示例](http://stackoverflow.com/help/mcve)。 – MikeCAT
这是函数不应该打印任何东西,我们给出了测试用例,并且它没有显示这个函数的输出。 –