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 alln; char board[11][11]; int jud(int a,int b) { int count = 0; if (a - 1 >= 0 && board[a-1][b] == '*') count++; if (b - 1 >= 0 && board[a][b-1] == '*') count++; if (a + 1 < alln && board[a+1][b] == '*') count++; if (b + 1 < alln && board[a][b+1] == '*') count++; if (a + 1 < alln && b + 1 < alln && board[a+1][b+1] == '*') count++; if (a - 1 >= 0 && b - 1 >= 0 && board[a-1][b-1] == '*') count++; if (a - 1 >= 0 && b + 1 < alln && board[a-1][b+1] == '*') count++; if (a + 1 < alln && b - 1 >= 0 && board[a+1][b-1] == '*') count++; return count; } int main() { char afterboard[11][11]; int i,j,flag,temp = 0; while (scanf("%d",&alln) != EOF) { for (i = 0;i < alln;i++) scanf("%s",board[i]); for (i = 0;i < alln;i++) scanf("%s",afterboard[i]); for (i = 0,flag = 0;i < alln;i++) { for (j = 0;j < alln;j++) { if (afterboard[i][j] == 'x' && board[i][j] != '*') afterboard[i][j] = jud(i,j) + '0'; else if (afterboard[i][j] == 'x' && board[i][j] == '*') { flag = 1; afterboard[i][j] = jud(i,j) + '0'; } } } if (temp != 0) printf("\n"); if (flag == 0) for (i = 0;i < alln;i++) printf("%s\n",afterboard[i]); else if (flag == 1) { for (i = 0;i < alln;i++) for (j = 0;j < alln;j++) if (board[i][j] == '*') afterboard[i][j] = '*'; for (i = 0;i < alln;i++) printf("%s\n",afterboard[i]); } temp = 1; } return 0; } 一次AC咯!!! Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator