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

为什么我这个提交总是runtime error 数组开的够大了,在自己的电脑上可以运行

Posted by songyang8464 at 2010-10-07 18:46:57 on Problem 1068
#include<iostream>
using namespace std;
char s[100];
int  p[50],w[50];

int main()
{
	int i,j,n,temp=0,count=0,flag=0,t=0,num,times;
	cin>>times;
	while(times--)
	{
	     cin>>n;
	     num=n;
	     memset(p,50,0);
             memset(s,100,'\0');
             memset(w,50,0);

	     for( i=1;i<=n;i++)
	    {  
		cin>>p[i];
		temp=p[i]-p[i-1];
		for(j=temp;j>0;j--)
			s[count++]='(';
		    s[count++]=')';
	     }
	  for( j=count-1;j>=0;j--)
		if(s[j]==')')
		{
			flag=t=0;
	       for( i=j-1;i>=0;i--)
	       { 
	           if(s[i]==')')
			     flag++;
			   else
			    {
		            if(s[i]=='('&&flag==0)
					{
			        w[--num]=t+1;
					break;
			        }
		             if(s[i]=='('&&flag!=0)
		            {
		             flag--;
		             t++;
		            }
		         }
		     }
	     }
	
		for(int i=0;i<n;i++)
			cout<<w[i];
		    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