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 |
路过那么多大神,求指点下我哪里错了,小弟无限感激#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator