我有这段代码:
#include <iostream>
using namespace std;
int recursivefunction(int NbProducts, int NbPlates, int prevlevel, int currentlevel, int thearray[] ) {
currentlevel = (prevlevel + 1);
if(prevlevel = 0) { currentlevel = 1; } //only ensures that the FIRST run has no issues with negatives
while(thearray[currentlevel] < (NbProducts - NbPlates + 1)) {
if(currentlevel = NbPlates) {
cout << thearray[currentlevel] << endl; //debug, do something to test full program
}
else recursivefunction(NbProducts, NbPlates, prevlevel, currentlevel, thearray[] );
}
}
int main() {
int NbProducts = 10, NbPlates = 3, prevlevel = 0, currentlevel = 0;
int thearray[100];
recursivefunction (NbProducts, NbPlates, prevlevel, currentlevel, thearray[]);
}
并且它一直给我“在'thearray'中'期望'之前预期的价值”。 忽略程序的其余部分,它现在没有做任何事情。如果我在这些括号内给出一个值,它会给我带来许多其他错误。有什么想法吗?
答案 0 :(得分:0)
当你调用这个函数时,它应该传递数组本身w / o []
recursivefunction (NbProducts, NbPlates, prevlevel, currentlevel, thearray);