About Me

About Me : I have been working as a Software Engineer for various international companies for four years.Currently, I am working as a full stack Javascript developer in Petronas(Malaysia).

Skills

Skills • Javascript •Typescript •Python •C •Java •ReactJs • Redux • VueJs • NestJs • React Testing Library • Django• PostgreSQL • MySQL • NodeJs • Git • Docker • Jira • Visual Studio Code • Slack

শনিবার, ১৭ জানুয়ারী, ২০১৫

UVA SOLUTION: 10189 - Minesweeper

#include<bits/stdc++.h>
#define READ freopen("in.txt","r",stdin);
#define WRITE freopen ("out.txt","w",stdout);
using namespace std;

int R[] = { -1, -1, -1, 0, 1, 1, 1, 0 };
int C[] = { -1, 0, 1, -1, -1, 0, 1, 1 };


int main()
{
   // READ WRITE
    int row, col,cas=0;
    char ary[101][101];
    while (~scanf("%d%d", &row, &col))
    {
        cas++;

        if (row == 0 && col == 0) break;
        if (cas != 1) printf("\n");


        for (int i = 0; i < row; i++) cin >> ary[i];

        printf("Field #%d:\n",cas);

        for (int i = 0; i < row; i++)
        {
            for (int j = 0; j < col; j++)
            {
                if (ary[i][j] == '*') continue;
                int count = 0;
                for (int k = 0; k < 8; k++) if (ary[i + R[k]][j + C[k]] == '*') count++;
                ary[i][j] = count+'0';
            }

        }

        for (int i = 0; i < row; i++) cout << ary[i] << endl;
        memset (ary,0,sizeof(ary));


    }

    return 0;
}

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন