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

Re:怎么老是ructime error?

Posted by hoho at 2003-10-16 13:07:01 on Problem 1068
In Reply To:怎么老是ructime error? Posted by:hoho at 2003-10-16 12:13:07
> #include<stdio.h>
> #include<stdlib.h>
> void change(int *num,int n)
> {
> 	int k=1,j,*arr;
> 	char *brac=(char *)malloc(2*n+1);
> 	arr=(int *)malloc(n);
> 	for(int i=1;i<=n;i++)
> 	{
> 		for(j=1;j<=num[i]-num[i-1];j++)
> 			brac[k++]='(';
> 		brac[k++]=')';
> 	}
> 	int stack[21];
> 	int jj=0,top=-1,count=0;
> 	for(int ii=1;ii<=2*n;ii++)
> 		if(brac[ii]=='(')
> 			stack[++top]=ii;
> 		else
> 		{
> 			arr[jj++]=(ii-stack[top]+1)/2;
> 			top--;
> 		}
> 	for(k=0;k<n-1;k++)
> 		printf("%d ",arr[k]);
> 	printf("%d\n",arr[k]);
> }
> void convert()
> {
> 	int testcase,n,i,j,*num=NULL;
> 	scanf("%d",&testcase);
> 	for(i=0;i<testcase;i++)
> 	{
> 		scanf("%d",&n);
> 		num=(int *)malloc(n+1);
> 		num[0]=0;
> 		for(j=1;j<n;j++)
> 			scanf("%d ",&num[j]);
> 		scanf("%d",&num[j]);
> 		change(num,n);
> 	}
> 	
> }
> int main()
> {
> 	convert();
> 	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