*#include <iostream>
using namespace std;
class Tree{
static int height[0];
public:
static int countBalanceTree(int h){
height[0]=height[1]=1;
for(int i=2;i<=h;i++){
height[i]=height[i-1]*(height[i-1]+2*height[i-2]);
}
return height[h];
}
};
int Tree::height[];
int main(void){
int h;
cout<<"Enter height = ";
cin>>h;
cout<<(Tree::countBalanceTree(h))<<" Balanced Tree can be create of height "<<h<<endl;
return 0;
}*
如果我將輸入h作爲任何東西(例如3),它仍然可以工作並打印輸出,但數組大小爲零。這個C++代碼如何工作?
問誰寫的?使用調試器來完成它? – Borgleader
你只是有一個直接的緩衝區溢出破壞內存... – VTT