#include<iostream> #include<cstdio> #include<vector> #include<cstring> #define db(a) cout << #a << " = " << a << endl #define db2(a, b) cout << #a << " = " << a << " " << #b << " = " << b << endl using namespace std; int n, m; int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1}; int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1}; vector<string> grid; char tonum(int x, int y) { int cont = 0; for (int i = 0; i < 8; i++) if (x + dx[i] >= 0 && x + dx[i] < n && y + dy[i] >= 0 && y + dy[i] < m) if (grid[x + dx[i]][y + dy[i]] == '*') cont++; return cont + '0'; } int main() { #ifdef dennisbot freopen("in.in", "r", stdin); freopen("ou.out", "w", stdout); #endif string linea; int field = 1; cin >> n >> m; while (1) { for (int i = 0; i < n; i++) { cin >> linea; grid.push_back(linea); } for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (grid[i][j] != '*') grid[i][j] = tonum(i, j); cout << "Field #" << field++ << ":"<< endl; for (int i = 0; i < n; i++) cout << grid[i] << endl; cin >> n >> m; if (n == 0 && m == 0) break; cout << endl; grid.clear(); } return 0; }
domingo, 29 de julio de 2012
10189 - Minesweeper, uva
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario