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 |
ac留念,注意数据超过20和\b的问题,附上代码#include<stdio.h> #include<string.h> void main() { int i,j,n; int k=0; int num=0,tmp; char a[200]={0}; int time; int jinzhanzuo=0;//表示需要进栈的左括号数目 scanf("%d",&time); while(time--) { scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&tmp); jinzhanzuo=tmp-jinzhanzuo; for(j=0;j<jinzhanzuo;j++) a[k++]='z'; for(j=k-1;j>=0;j--) { if(a[j]=='y') num++; if(a[j]=='z') { a[j]='o';//表示出栈一个左 break; } } a[k++]='y'; jinzhanzuo=tmp; printf("%d ",num+1); num=0; } printf("\n"); memset(a,0,sizeof(a)); jinzhanzuo=0; k=0; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator