| ||||||||||
| 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 | |||||||||
一直WA,求指正错误#include <cstdio>
#include <cstring>
#define maxN 10005
using namespace std;
int main()
{
char A[maxN];
int n=0;
while(1)
{
gets(A);
if(A[0]=='#')
break;
int h1=1,h2=1,t1=1,t2=1;//len;
//memset(A,'\0',sizeof(A));
//len=strlen(A);
for(int i=1;A[i]!='\0';i++)
{
if(A[i]=='d' && A[i-1]!='u')
{
h1++;
h2++;
}
if(A[i]=='d' && A[i-1]=='u')
{
h1++;
h2+=2;
}
if(A[i]=='u')
{
h1--;
h2--;
}
if(h1>t1)
t1=h1;
if(h2>t2)
t2=h2;
}
printf("Tree %d: %d => %d\n",++n,t1,t2);
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator