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

一直WA,求指正错误

Posted by iChinxu at 2018-03-04 10:10:38 on Problem 3437
#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:
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