| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
求指导啊,stack around the variable was corrupted,很奇怪的错误诶。。。上代码,求大牛帮忙指正错误
#include <iostream>
using namespace std;
const int maxn = 32;
int main(){
int ans[maxn];
int n;
memset(ans,0,sizeof(ans));
ans[0] = 1;
ans[2] = 3;
for (int i = 4; i <= maxn; i+=2)
{
ans[i] = 4 * ans[i-2] - ans[i-4];
}
while (scanf("%d",&n) && n != -1)
{
if (n % 2 != 0)
cout << 0 << endl;
else
cout << ans[n] << endl;
}
//system("pause");
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator