Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.4 kB
0
Indexable
Never
#include <iostream>
#include <fstream>
#include <stdint.h>
#include <algorithm>
#include <string>
#include "Header.h" 
using namespace std;
int main() {
	int a, b, c;
	int x, y;
	cin >> a >> b >> c;
	vector <vector <char>> mas;
	for (int i = 0; i < a; i++){
		vector <char> k;
		for (int j = 0; j < b; j++) {
			k.push_back('0');
		}
		mas.push_back(k);
	}
	for (int i = 0; i < c; i++){
		cin >> x >> y;
		mas[y - 1][x - 1] = '*';
	}
	for (int i = 0; i < a; i++){
		for (int j = 0; j < b; j++) {
			if (mas[i][j] == '*') {
				if (i - 1 >= 0 && mas[i - 1][j] != '*') {
					mas[i-1][j]+=1;
				}

				if (i - 1 >= 0 && j +1 < b && mas[i-1][j+1] != '*') {
					mas[i - 1][j+1] += 1;
				}

				if (i - 1 >= 0 && j - 1 >= 0 && mas[i-1][j-1] != '*') {
					mas[i - 1][j-1] += 1;
				}

				if (j-1 >= 0 && mas[i][j-1] != '*') {
					mas[i][j-1] += 1;
				}

				if (j + 1 < b && mas[i][j+1] != '*') {
					mas[i][j+1] += 1;
				}

				if (i <= a && mas[i+1][j] != '*') {
					mas[i + 1][j] += 1;
				}

				if (i <= a && j-1 >= 0 && mas[i+1][j-1] != '*') {
					mas[i + 1][j - 1] += 1;
				}

				if (i < a && j+1 < b && mas[i+1][j+1] != '*') {
					mas[i + 1][j + 1] += 1;
				}

			}
		}
	}
	for (vector <char> j:mas){
		for (char h : j) {
			cout << h << ' ';
		}
		cout << '\n';
	}
}