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 |
Re:哭死 在你们北大上AC 在工大上就是不AC 郁闷中!!!!!!!!!!!!!!!!!!In Reply To:哭死 在你们北大上AC 在工大上就是不AC 郁闷中!!!!!!!!!!!!!!!!!! Posted by:huaixiaozi at 2008-01-17 14:01:44 > #include <stdio.h> > #include <stdlib.h> > > int main() > { > char a[11][15]; > char b[11][15]; > int m,i,j,c,d,flag,count; > > while (scanf("%d",&m)!=EOF) > { > for (i=0;i<m;i++) > { > scanf("%s",a[i]); > } > for (i=0;i<m;i++) > { > scanf("%s",b[i]); > } > flag=0; > for (i=0;i<m;i++) > { > for (j=0;j<m;j++) > { > if (b[i][j]=='x'&&a[i][j]=='*') > { > flag=1; > goto exit; > } > } > } > exit: > ; > if (flag==1) > { > for (i=0;i<m;i++) > { > for (j=0;j<m;j++) > { > if (b[i][j]=='x'&&a[i][j]!='*') > { > count=0; > if (c==0) > { > for (c=i;c<=i+1;c++) > { > if (j==0) > { > for (d=j;j<=j+1;j++) > { > if (a[c][d]=='*') > { > count++; > } > } > } > else > { > for (d=j-1;j<=j+1;j++) > { > if (a[c][d]=='*') > { > count++; > } > } > } > } > } > else > { > for (c=i-1;c<=i+1;c++) > { > if (j==0) > { > for (d=j;d<=j+1;d++) > { > if (a[c][d]=='*') > { > count++; > } > } > } > else > { > for (d=j-1;d<=j+1;d++) > { > if (a[c][d]=='*') > { > count++; > } > } > } > } > } > printf("%d",count); > } > if (b[i][j]=='x'&&a[i][j]=='*') > { > printf("*"); > } > if (b[i][j]=='.') > { > if (a[i][j]=='*') > { > printf("*"); > } > else > { > printf("."); > } > } > } > printf("\n"); > } > printf("\n"); > } > else > { > for (i=0;i<m;i++) > { > for (j=0;j<m;j++) > { > if (b[i][j]=='x') > { > count=0; > if (c==0) > { > for (c=i;c<=i+1;c++) > { > if (j==0) > { > for (d=j;j<=j+1;j++) > { > if (a[c][d]=='*') > { > count++; > } > } > } > else > { > for (d=j-1;j<=j+1;j++) > { > if (a[c][d]=='*') > { > count++; > } > } > } > } > } > else > { > for (c=i-1;c<=i+1;c++) > { > if (j==0) > { > for (d=j;d<=j+1;d++) > { > if (a[c][d]=='*') > { > count++; > } > } > } > else > { > for (d=j-1;d<=j+1;d++) > { > if (a[c][d]=='*') > { > count++; > } > } > } > } > } > printf("%d",count); > } > if (b[i][j]=='.') > { > printf("."); > } > } > printf("\n"); > } > printf("\n"); > } > } > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator