Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main() {
- int n, m;
- cin >> m >> n;
- vector<vector<char>> mat(m, vector<char>(n, ' '));
- int k;
- cin >> k;
- for (int i = 0; i < k; ++i) {
- int x, y;
- cin >> x >> y, --x, --y;
- mat[x][y] = '*';
- }
- for (int i = 0; i < m; ++i) {
- for (int j = 0; j < n; ++j) {
- if (mat[i][j] == '*') {
- cout << "* ";
- } else {
- int cnt = 0;
- for (int t = max(i - 1, 0); t <= min(m - 1, i + 1); ++t){
- for (int z = max(j - 1, 0); z <= min(n - 1, j + 1); ++z){
- cnt += mat[t][z] == '*';
- }
- }
- cout << cnt << ' ';
- }
- }
- cout << '\n';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement