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

求高手帮看下为什么内存这么大?

Posted by csdnail at 2010-06-14 12:45:14 on Problem 1953
G++内存消耗728k,可我只开了一个三元数组而已,之前用45元素的数组保存结果也没这么大。不知道内存都花在哪了?

#include <iostream>
using namespace std;

int main()
{

	int t,count=0,array[3];
	short i,n;
	cin>>t;
	while(t--)
	{
		array[0]=2;
		array[1]=3;
		cin>>n;
		for(i=2;i<n;i++)
		{
			array[i%3]=array[(i-1)%3]+array[(i-2)%3];
		}
		count++;
		cout<<"Scenario #"<<count<<":"<<endl;
		cout<<array[(n-1)%3]<<endl;
		cout<<endl;
	}
	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