Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么???为什么我的程序在下面这组数据下的结果是-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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator