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 zfeagle at 2012-09-13 20:17:20 on Problem 3561 and last updated at 2012-09-13 20:17:38
#include<stdio.h>
int main()
{
     char s[100][100],ch;
     int t,a,b,i,j,k,x,y,vis;
     scanf("%d",&t);
     //t+=1;
     while(t--)
     {
         scanf("%d%d",&a,&b);
         vis=k=x=y=0;
         for(i=0;i<a;i++)
         scanf("%s",s[i]);
         for(i=0;i<a;i++)
             for(j=0;j<b;j++)
                 if(s[i][j]!='.')
                 {
                 vis++;
                 if(vis==1)
                 {
                 ch=s[i][j];
                 x=i;y=j;
                 }
                 }
         if(vis==0)
              printf("INCORRECT\n");
         else
         {          
         if(ch=='\\')
         {
         while((k+x)<b&&(k+y)<a)
         {
             k++;
             if(s[x][y]!=s[x+k][y+k])
             break;                          
         }
             if(k!=vis)
                 printf("INCORRECT\n"); 
             else
                 printf("CORRECT\n"); 
         }
         if(ch=='/')
         {
              while((x-k)>=0&&(y-k)>=0)
              {
                   k++;
                   if(s[x][y]!=s[x-k][y-k])
                   break;
              }
                   if(k==vis)
                   printf("CORRECT\n"); 
                   else
                   printf("INCORRECT\n");                                                   
         }
         if(ch=='-')
         {
             while((x+k)<b)
             {
                  k++;
                  if(s[x][y]!=s[x+k][y]) 
                  break;             
             }          
             if(k==vis)
             printf("CORRECT\n");
             else
             printf("INCORRECT\n");   
         }
         if(ch=='|')
         {
             while((y+k)<a)
             {
                 k++;
                 if(s[x][y]!=s[x][y+k])
                 break;              
             } 
             if(k==vis)
             printf("CORRECT\n"); 
             else
             printf("INCORRECT\n");           
         }
         }                                
     }   
}

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