代码: #include using namespace std; int main(){ int f[1000]={0,1}; int n; cout<<"n = "; cin>>n; for(int i = 2;i <= n; i++){ f[i] = 2*f[i-1] + 1; } cout<<“N层汉诺塔移动次数为:”<<f[n]<<endl; return 0; }