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 liuzb1987 at 2008-05-05 08:53:19 on Problem 1250
#include"stdio.h"
#include"string.h"
main()
{
   int beds,length,top,i,j,k,result;
   char person[1000],state[1000];
   while(EOF!=scanf("%d",&beds)&&beds!=0)
     {
          for(i=0;i<1000;i++)
            {
                 person[i]=state[i]=0;               
            }
          top=0;
          result=0;
          scanf("%s",person);
          length=strlen(person);
          for(i=0;i<length;i++)
            {
                 if(state[person[i]]=='1')
                   {
                        top-=1;
                        state[person[i]]=0;              
                   }                 
                 else 
                   {
                        state[person[i]]='1';
                        top+=1;                                
                   }
                 result=result>top?result:top;
            }               
          if(result-beds<=0)
            {
                 printf("All customers tanned successfully.\n");               
            }
          else
            {
                 printf("%d customer(s) walked away.\n",result-beds);    
            }
     }     
}

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