我试图调用该函数
(breaks <- data.frame(
start = index(z[c(1, bp$breakpoints+1)]),
end = c(index(z[bp$breakpoints]), index(z[length(z)]))
))
# start end
# 1 2015-01-14 00:00:00 2015-01-14 07:00:00
# 2 2015-01-14 08:00:00 2015-01-14 09:00:00
# 3 2015-01-14 10:00:00 2015-01-14 17:00:00
# 4 2015-01-14 18:00:00 2015-01-14 20:00:00
# 5 2015-01-14 21:00:00 2015-01-14 23:00:00
fits <- lapply(seq_len(nrow(breaks)), function(x) {
idx <- index(z)>=breaks[x, 1] & index(z)<=breaks[x, 2]
fit <- lm(z[idx]~index(z[idx]))
})
sapply(fits, coefficients)
# [,1] [,2] [,3] [,4] [,5]
# (Intercept) -4.048094e+02 -1.007876e+05 8.358223e+03 3.750603e+04 1.873346e+04
# index(z[idx]) 2.850529e-07 7.091667e-05 -5.880291e-06 -2.638889e-05 -1.318056e-05
在int Even( int a[][MAX_COLUMNS], int length, int width)
内将输出打印给用户。
运行程序后,我收到以下错误
`int Even(int,int,int) connot convert argument 1 from int [3][2] to int
这是代码, 感谢您抽出宝贵时间帮助我。
main
答案 0 :(得分:-2)
你应该避免前瞻性声明(特殊情况除外)。在你的Q导致你错误。完整代码:
#include <iostream>
#define MAX_ROWS 3
#define MAX_COLUMNS 2
using namespace std;
int Even( int a[][MAX_COLUMNS], int length, int width){
int sum = 0;
int i;
int j;
for (i = 0; i < length, i++;){
for (j = 0; j < width, j++;){
if (a[i][j] % 2 == 0){
sum++;
}
}
}
return sum;
}
int main(){
int A[MAX_ROWS][MAX_COLUMNS] = { { 3, 2 }, { 4, 5 }, { 2, 2 } };
cout << "There are " << Even(A,MAX_ROWS,MAX_COLUMNS) << " even numbers in the matrix." << endl;
cout << "Goodbye :-)" << endl;
system("PAUSE");
return 0;
}