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 |
Re:怎么老是ructime error?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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator