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

ac留念,注意数据超过20和\b的问题,附上代码

Posted by happyboy1986 at 2011-06-12 12:19:19 on Problem 1068
#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:
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