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

路过那么多大神,求指点下我哪里错了,小弟无限感激

Posted by 2012082324 at 2013-10-20 17:54:42 on Problem 3437
#include<stdio.h>
#include<string.h>
int main()
{
	char s[20011];
	int i, j, d1, d2, c, top, count=1;
	while(scanf("%s", s)&&strcmp(s, "#")!=0)
	{
		d1= d2 = top = c = 0;
		for(i=0;s[i];i++)
		{
			if(s[i]=='d') c++;
			else
			{
				if(d1<c) d1 = c;
				c = 0;
			}
		}
		for(i=0; s[i]; i++)
		{
			if(s[i]=='d')top++;
			else
			{
				i++;
				if(s[i]=='u'||s[i]==0)
				{
					if(top>d2) d2 = top;
					top--;
				}
				i--;
			}
		}
		printf("Tree %d: %d => %d\n", count++,d1,d2);
	}
}

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