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

sample 都过了~~~可为什么wa ??大牛请入

Posted by dong930 at 2007-08-02 17:16:56 on Problem 3095
#include<stdio.h>
#include<string.h>
main()

{
 int flag=1,i,j,len,k;
 int t;
 char s[100];     
 while(scanf("%s",s) && s[0]!='#')
 {
    t=k=0;flag=1;
    len=strlen(s);
    if(s[0]=='.' || s[0]=='/')t+=100;
    else 
      if(s[0]=='\\')
      {
       for(j=1;j<len;j++)
        {
          if(s[j]=='|' || s[j]=='\\' || s[j]=='/') break;
           else if(s[j]=='.'){t+=100;flag=0;break;}
        } 
        if(j==len && flag)t+=100;             
      }
    else
     if(s[0]=='|')
         {
           for(j=1;j<len;j++)
           {
             if(s[j]=='|' || s[j]=='\\' || s[j]=='/'){break;}
              else if(s[j]=='.'){k+=100;flag=0;break;}
            } 
           if(j==len && flag)k+=100; 
           t+=(k+100)/2;
         }            
     k=0; flag=1;
      

    for(i=1;i<len-1;i++)
     {
       if(s[i]=='/')
        {
          for(j=i-1;j>=0;j--)
           {
             if(s[j]=='|' || s[j]=='\\' || s[j]=='/') break;
             else if(s[j]=='.'){t+=100;flag=0;break;}
           } 
          if(j==-1 && flag)t+=100;             
        }
       else
         if(s[i]=='.')t+=100;
       else
         if(s[i]=='\\')
           {
            for(j=i+1;j<len;j++)
             {
               if(s[j]=='|' || s[j]=='\\' || s[j]=='/') break;
               else if(s[j]=='.'){t+=100;flag=0;break;}
             } 
            if(j==len && flag)t+=100;             
           }
         else
         if(s[i]=='|')
          {
            for(j=i+1;j<len;j++)
            {
              if(s[j]=='|' || s[j]=='\\' || s[j]=='/') break;
              else if(s[j]=='.'){k+=100;flag=0;break;}
             } 
            if(j==len && flag)k+=100; 
            flag=1;
            for(j=i-1;j>=0;j--)
             {
              if(s[j]=='|' || s[j]=='\\' || s[j]=='/') break;
              else if(s[j]=='.'){k+=100;flag=0;break;}
             } 
             if(j==-1 && flag)k+=100;
             t+=k/2;                              
          }  
          k=0; flag=1;      
          
                                                       
     } 
     if(s[len-1]=='.' || s[len-1]=='\\')t+=100;
     else
      if(s[len-1]=='|')
       {
      
          for(j=i-1;j>=0;j--)
           {
              if(s[j]=='|' || s[j]=='\\' || s[j]=='/') break;
              else if(s[j]=='.'){k+=100;flag=0;break;}
           } 
          if(j==-1 && flag)k+=100;
          t+=(100+k)/2;
              
       } 
       else
        if(s[len-1]=='/')
          {
            for(j=i-1;j>=0;j--)
             {
              if(s[j]=='|' || s[j]=='\\' || s[j]=='/') break;
              else if(s[j]=='.'){t+=100;flag=0;break;}
             } 
             if(j==-1 && flag)t+=100;
                                       
          }         
          
                                
     printf("%d\n",t/len);   
                
 }
    
}

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