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 |
求教啊~~怎么试怎么对啊到底哪错了呢,请高手指点一二!!!(C程序,方法有点笨!)#include<stdio.h> #include<string.h> void main() {char s[101][101]; int l,m,n,i,j,count,end[101],k=0; for(l=0;;l++) {scanf("%d %d",&m,&n); if(m==0) break; for(i=0;i<m;i++) scanf("%s",&s[i]); for(i=0,count=0;i<m;i++) for(j=0;j<n;j++) {if(s[i][j]=='*'&&s[i-1][j-1]=='0') if(s[i-1][j]=='@') s[i-1][j]='0'; if(s[i][j]=='*'&&s[i-1][j-1]=='0') if(s[i][j-1]=='@') s[i][j-1]='0'; if(s[i][j]=='*'&&s[i-1][j]=='0') if(s[i-1][j-1]=='@') s[i-1][j-1]='0'; if(s[i][j]=='*'&&s[i-1][j]=='0') if(s[i][j-1]=='@') s[i][j-1]='0'; if(s[i][j]=='*'&&s[i-1][j]=='0') if(s[i-1][j+1]=='@') s[i-1][j+1]='0'; if(s[i][j]=='*'&&s[i-1][j]=='0') if(s[i][j+1]=='@') s[i][j+1]='0'; if(s[i][j]=='*'&&s[i-1][j+1]=='0') if(s[i-1][j]=='@') s[i-1][j]='0'; if(s[i][j]=='*'&&s[i-1][j+1]=='0') if(s[i][j+1]=='@') s[i][j+1]='0'; if(s[i][j]=='*'&&s[i][j-1]=='0') if(s[i-1][j-1]=='@') s[i-1][j-1]='0'; if(s[i][j]=='*'&&s[i][j-1]=='0') if(s[i-1][j]=='@') s[i-1][j]='0'; if(s[i][j]=='*'&&s[i][j-1]=='0') if(s[i+1][j-1]=='@') s[i+1][j-1]='0'; if(s[i][j]=='*'&&s[i][j-1]=='0') if(s[i+1][j]=='@') s[i+1][j]='0'; if(s[i][j]=='*'&&s[i][j+1]=='0') if(s[i-1][j]=='@') s[i-1][j]='0'; if(s[i][j]=='*'&&s[i][j+1]=='0') if(s[i-1][j+1]=='@') s[i-1][j+1]='0'; if(s[i][j]=='*'&&s[i][j+1]=='0') if(s[i+1][j]=='@') s[i+1][j]='0'; if(s[i][j]=='*'&&s[i][j+1]=='0') if(s[i+1][j+1]=='@') s[i+1][j+1]='0'; if(s[i][j]=='*'&&s[i+1][j-1]=='0') if(s[i][j-1]=='@') s[i][j-1]='0'; if(s[i][j]=='*'&&s[i+1][j-1]=='0') if(s[i+1][j]=='@') s[i+1][j]='0'; if(s[i][j]=='*'&&s[i+1][j]=='0') if(s[i][j-1]=='@') s[i][j-1]='0'; if(s[i][j]=='*'&&s[i+1][j]=='0') if(s[i+1][j-1]=='@') s[i+1][j-1]='0'; if(s[i][j]=='*'&&s[i+1][j]=='0') if(s[i+1][j+1]=='@') s[i+1][j+1]='0'; if(s[i][j]=='*'&&s[i+1][j]=='0') if(s[i][j+1]=='@') s[i][j+1]='0'; if(s[i][j]=='*'&&s[i+1][j+1]=='0') if(s[i][j+1]=='@') s[i][j+1]='0'; if(s[i][j]=='*'&&s[i+1][j+1]=='0') if(s[i+1][j]=='@') s[i+1][j]='0'; if(s[i][j]=='@') if(s[i-1][j-1]=='0'||s[i-1][j]=='0'||s[i-1][j+1]=='0'||s[i][j-1]=='0'||s[i][j+1]=='0'||s[i+1][j-1]=='0'||s[i+1][j]=='0'||s[i+1][j+1]=='0') s[i][j]='0'; if(s[i][j]=='@'&&s[i-1][j-1]!='0'&&s[i-1][j]!='0'&&s[i-1][j+1]!='0'&&s[i][j-1]!='0'&&s[i][j+1]!='0'&&s[i+1][j-1]!='0'&&s[i+1][j]!='0'&&s[i+1][j+1]!='0') {count++;s[i][j]='0';} } end[k++]=count; } for(i=0;i<k;i++) printf("%d\n",end[i]); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator