Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main() {
- string field[8];
- for(int i = 0; i < 8; i++) {
- cin >> field[i];
- }
- string newfield[8];
- for(int i = 0; i < 8; i++) {
- string stroka = "";
- for(int j = 0; j < 8; j++) {
- int count = 0;
- if(field[i][j] == '*') {
- stroka += '*';
- continue;
- }
- if(j - 1 >= 0) {
- if(field[i][j - 1] == '*') {
- count++;
- }
- }
- if(j + 1 < 8) {
- if(field[i][j + 1] == '*')
- count++;
- }
- if(i - 1 >= 0) {
- if(j - 1 >= 0) {
- if(field[i - 1][j - 1] == '*') {
- count++;
- }
- }
- if(field[i - 1][j] == '*') {
- count++;
- }
- if(j + 1 < 8) {
- if(field[i - 1][j + 1] == '*') {
- count++;
- }
- }
- }
- if(i + 1 < 8) {
- if(j - 1 >= 0) {
- if(field[i + 1][j - 1] == '*') {
- count++;
- }
- }
- if(field[i + 1][j] == '*') {
- count++;
- }
- if(j + 1 < 8) {
- if(field[i + 1][j + 1] == '*') {
- count++;
- }
- }
- }
- stroka += count + '0';
- }
- newfield[i] = stroka;
- }
- for(int i = 0; i < 8; i++) {
- cout << newfield[i] << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement