Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求指导啊,stack around the variable was corrupted,很奇怪的错误诶。。。

Posted by johnny0707 at 2013-02-04 14:17:55 on Problem 2663
上代码,求大牛帮忙指正错误

#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator