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-10-22 13:09:54 on Problem 1307
wa 实在不知道错在哪了

#include"stdio.h"
#include"string.h"
int top,hang,lie,x[1000],y[1000],matrix_judge[20][20],matrix_result[40][40];
void Let_us_go(int x_start,int y_start,int x_end,int y_end)
{
   int i,j,count;
   top=2;
   count=0;
   x[0]=x_start;
   y[0]=y_start;
   while(x[count]!=x_end||y[count]!=y_end)
     {
          
          if(y[count]-1>=0&&matrix_judge[x[count]][y[count]-1]!=1&&matrix_judge[x[count]][y[count]-1]!=3&&matrix_result[x[count]][y[count]-1]==0)
            {
                 x[count+1]=x[count];
                 y[count+1]=y[count]-1;
                 count+=1;
                 matrix_result[x[count]][y[count]]=top;
                 top+=1;
            }
          else if(x[count]-1>=0&&matrix_judge[x[count]-1][y[count]]!=2&&matrix_judge[x[count]-1][y[count]]!=3&&matrix_result[x[count]-1][y[count]]==0)
            {
                 x[count+1]=x[count]-1;
                 y[count+1]=y[count];
                 count+=1;
                 matrix_result[x[count]][y[count]]=top;
                 top+=1;                 
            }
          else if(y[count]+1<lie&&matrix_judge[x[count]][y[count]]!=1&&matrix_judge[x[count]][y[count]]!=3&&matrix_result[x[count]][y[count]+1]==0)
            {
                 x[count+1]=x[count];
                 y[count+1]=y[count]+1;
                 count+=1;
                 matrix_result[x[count]][y[count]]=top;
                 top+=1;                 
            }
          else if(x[count]+1<hang&&matrix_judge[x[count]][y[count]]!=2&&matrix_judge[x[count]][y[count]]!=3&&matrix_result[x[count]+1][y[count]]==0)
            {
                 x[count+1]=x[count]+1;
                 y[count+1]=y[count];
                 count+=1;
                 matrix_result[x[count]][y[count]]=top;
                 top+=1;                     
            }
          else
            {
                 matrix_result[x[count]][y[count]]=9999;
                 count-=1;
                 top-=1;
            }
     }
}
main()
{
   char frame[200][200];
   int i,j,m,n,judge,x_start,y_start,x_end,y_end,count=1;
   while(EOF!=scanf("%d%d%d%d%d%d",&hang,&lie,&x_start,&y_start,&x_end,&y_end))
{
   if(hang==0&&lie==0&&x_start==0&&y_start==0&&x_end==0&&y_end==0)
     {
          break;                                             
     }
   x_start-=1;
   y_start-=1;
   x_end-=1;
   y_end-=1;
   for(i=0;i<hang;i++)
     {
          for(j=0;j<lie;j++)
            {
                 scanf("%d",&matrix_judge[i][j]);  
                 matrix_result[i][j]=0;
            }                
     }
   for(i=0;i<200;i++)
     {
          for(j=0;j<200;j++)
            {
                 frame[i][j]=0;                 
            }
     }
   x[0]=x_start;
   y[0]=y_start;
   matrix_result[x[0]][y[0]]=1;
   Let_us_go(x_start,y_start,x_end,y_end);   
   printf("Maze %d\n\n",count++);
   for(i=0;i<2*hang+1;i++)
     {
          if(i%2==0)
          {
          for(j=0;j<4*lie+1;j++)
            {
                 
                 if(j%4==0)
                   {
                        frame[i][j]='+';       
                   }
                 else if(i==0||i==2*hang)
                   {
                        frame[i][j]='-';                     
                   }
                 else if(i>=2&&(matrix_judge[(int)i/2-1][(int)j/4]==2||matrix_judge[(int)i/2-1][(int)j/4]==3))
                   {
                        frame[i][j]='-';                                                                                
                   }
            }     
          }
          else 
          {
          for(j=0;j<4*lie+1;j++)
            {
                 if(j==0||j==4*lie)
                   {
                        frame[i][j]='|';
                   }
                 else if(i<=2*hang&&(matrix_judge[(i-1)/2][(int)j/4]==1||matrix_judge[(i-1)/2][(int)j/4]==3))
                   {
                        frame[i][(int(j/4)+1)*4]='|';
                   }
                 
            }     
          }      
     }
   for(i=0;i<hang;i++)
     {
          for(j=0;j<lie;j++)
            {
                 if(matrix_result[i][j]==9999)
                   {
                        frame[2*i+1][4*j+1]='?';
                        frame[2*i+1][4*j+2]='?';
                        frame[2*i+1][4*j+3]='?';
                   }               
                 else if(matrix_result[i][j]>0&&matrix_result[i][j]<=9)
                   {
                        frame[2*i+1][4*j+3]=matrix_result[i][j]+48;
                   }
                 else if(matrix_result[i][j]>9&&matrix_result[i][j]<=99)
                   {
                        frame[2*i+1][4*j+1]=0;
                        frame[2*i+1][4*j+2]=matrix_result[i][j]/10+48;      
                        frame[2*i+1][4*j+3]=matrix_result[i][j]%10+48;                           
                   }
                 else if(matrix_result[i][j]>99&&matrix_result[i][j]<=999)
                   {
                        frame[2*i+1][4*j+1]=matrix_result[i][j]/100+48;
                        frame[2*i+1][4*j+2]=matrix_result[i][j]%100/10+48;
                        frame[2*i+1][4*j+3]=matrix_result[i][j]%10+48;
                   }
            }                
     }
   for(i=0;i<2*hang+1;i++)
     {
          for(j=0;j<4*lie+1;j++)
            {
                 printf("%c",frame[i][j]);                   
            }
          printf("\n");
     }
   printf("\n\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