Minersweeper

 avatar
user_3763047219
c_cpp
2 years ago
766 B
3
Indexable
Never
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
int main()
{
	int arr[6][6] = { 0 };
	for (int i = 1; i <=4; i++) {
		for (int j = 1; j <= 4; j++) {
			scanf("%d", &arr[i][j]);
		}
	}

	for (int i = 1; i <= 4; i++) {
		for (int j = 1; j <= 4; j++) {
			if (arr[i][j] == 0) {
				int count = 0;
				for (int k = -1; k <= 1; k++) {
					for (int h = -1; h <= 1; h++) {
						if (arr[i + k][j + h] == -1) {
							count = count + 1;
						}
					}
				}
				arr[i][j] = count;
			}
		}
	}

	for (int i = 1; i <= 3; i++) {
		for (int j = 1; j <= 3; j++) {
			printf("%d ", arr[i][j]);
		}
		printf("%d", arr[i][4]);
		printf("\n");
	}
	for (int j = 1; j <= 3; j++) {
		printf("%d ", arr[4][j]);
	}
	printf("%d", arr[4][4]);
	
}