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 chenhaifeng at 2006-10-05 10:59:57 on Problem 1562
为什么我的程序在下面这组数据下的结果是-1
其他的都正确
10 20
*@******@@@@*****@@@
**@***@@****@@**@***
*@@@@@@*@***@@@@****
@@****@@@@***@@@****
*@***@@@@@*****@@@@@
@@@@@@*****@@***@**@
*@@****@@@@@@***@@@@
*@@@***@@*@*@****@**
@@@@****@***@@*@*@**
*@@@@@@@@*****@*@***
#include <stdio.h>
#include <string.h>
int main()
{
    int m,n;
    while(scanf("%d%d",&m,&n)&&m!=0)
    {
        int i,j,num;
        char map[110][110]={0};
        int flag[110][110]={0};
        for(i=1;i<=m;i++)
        {
            getchar();
            scanf("%s",map[i]+1);
        }
      num=0;
      for(i=1;i<=m;i++)
      for(j=1;j<=n;j++)
      if(map[i][j]=='@')
     {
            if(map[i][j-1]!='@'&&map[i][j+1]!='@'&&map[i-1][j-1]!='@'&&map[i-1][j]!='@'
              &&map[i-1][j+1]!='@'&&map[i+1][j-1]!='@'&&map[i+1][j]!='@'&&map[i+1][j+1]!='@')
              {num++;flag[i][j]=num;}
               
            else if(map[i-1][j-1]!='@'&&map[i-1][j]!='@'&&map[i-1][j+1]!='@'&&map[i][j-1]!='@')
                       {num++;flag[i][j]=num;}
                      
            else
            {
                if(map[i-1][j-1]=='@')flag[i][j]=flag[i-1][j-1];
                if(map[i-1][j]=='@')flag[i][j]=flag[i-1][j]; 
                if(map[i][j-1]=='@')flag[i][j]=flag[i][j-1];           
                if(map[i-1][j+1]=='@')
               {
                    if(flag[i][j]==0)flag[i][j]=flag[i-1][j+1];
                    else if(flag[i][j]!=0)
                    {
                        if(flag[i][j]!=flag[i-1][j+1])
                        {flag[i-1][j+1]=flag[i][j];num--;}
                     }                      
                }
            }
      }
      printf("%d\n",num);
    }
    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