10189 - Minesweeper

All about problems in Volume CI. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

10189 - Minesweeper

Postby dejavu_logic » Sat Mar 06, 2010 9:10 am

Hello I don't know why I got WA all the time
The output file had the same output though even the number of endline and the number of character there
are exactly the same with the sample output

Code: Select all
#include<iostream>
#include<fstream>

using namespace std;

int main(){
   
    long cols = 0, rows = 0;
    long nThField = 0;
    long mines = 0;
    long checkedRow = 0;
    long checkedCol = 0;
   
    while (cin>>rows>>cols){// get # of row n col
          char field[rows][cols];
         
          if (!rows && !cols) break;
          else if (nThField > 0) cout<<"\n";
         
          for (int i = 0; i < rows; i++){// iterate row
              for (int j = 0; j < cols; j++){// iterate col
                  cin>>field[i][j];
              }
          }
         
          //output the value
          nThField++;
          cout<<"Field #"<<nThField<<":"<<"\n";
          for (int i = 0; i < rows; i++){// iterate row
              for (int j = 0; j < cols; j++){// iterate col
                  if (field[i][j] == '.'){//print the number of mine around
                     // checking for possible mine around in 3x3 area
                     mines = 0;
                     for (int tRow = -1; tRow <= 1; tRow++){
                         for (int tCol = -1; tCol <= 1; tCol++){
                             checkedRow = i + tRow;
                             checkedCol = j + tCol;
                             if (checkedRow < 0 || checkedCol < 0) continue;// if col or row out of bound
                             if (field[i + tRow][j + tCol] == '*'){
                                mines++;
                             }
                         }
                     }
                     cout<<mines;
                  } //end of printing the number of mine
                  else cout<<'*'; //print the mine
              }// end iterating col
              cout<<"\n";
          }// end iterating row
         
    }
   
    return 0;
}


Any help would be very appreciated
dejavu_logic
New poster
 
Posts: 6
Joined: Sat Mar 06, 2010 8:30 am

Why WA?

Postby mintae71 » Wed Mar 10, 2010 10:09 am

Hello.
First, I'm sorry of my bad english.....
ok, then, lets start.
I don't know why this is WA...
I think because of newline part.
Plz help..........
Code: Select all
Removed after AC
mintae71
New poster
 
Posts: 18
Joined: Tue Jan 19, 2010 10:50 am

Re: 10189 - Minesweeper

Postby amishera » Sat Mar 27, 2010 4:24 am

This is a rather silly problem and I tried with all possible inputs but still not accepted. I checked with following testcases:

1. minimum
1 1
.
1 1
*

2. maximum
*** upto 100
*** upto 100
repeat until 100

3. for each position I test for mine
4 4
*...
....
....
4 4
.*..
....
....
....

lastly
4 4
....
....
....
...*

4. for each postion I put a '.' and surround it with mines
4 4
.***
****
****
****
4 4
*.**
****
****
****
lastly
4 4
****
****
****
***.

I thought that these are reasonable and representative sets of testcases. But still WA. I am not sure what else could I test for. I would be glad if someone throw some light on further strategy to test this thing.

BTW I incorporated some of the testcases mentioned earlier in the posts and it seemed to pass. I also tested for blank line in-between such as:

Field #51:
****
****
****
*5**

Field #52:
****
****
****
***3

Thanks.
amishera
New poster
 
Posts: 38
Joined: Sat Dec 27, 2008 10:42 pm

Re: 10189 - Minesweeper

Postby sajnt » Fri Jun 18, 2010 10:06 pm

Code: Select all
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i,a,b) for (int _n(b), i(a); i < _n; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQUE(c) SORT(c),(c).resize(unique(ALL(c))-(c).begin())
#define ST first
#define ND second
#define PB push_back
#define MP make_pair
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPII;
typedef vector<VI> VVI;

char A[105][105];
char ANS[105][105];

char count(int i, int j)
{
   char sum = 0;
   if ( A[i][j] == '*' ) return '*'-'0';
   if ( A[i-1][j] == '*' ) sum++;
   if ( A[i-1][j+1] == '*' ) sum++;
   if ( A[i][j+1] == '*' ) sum++;
   if ( A[i+1][j+1] == '*' ) sum++;
   if ( A[i+1][j] == '*' ) sum++;
   if ( A[i+1][j-1] == '*' ) sum++;
   if ( A[i][j-1] == '*' ) sum++;
   if ( A[i-1][j-1] == '*' ) sum++;
   return sum;
}

int main()
{
   int n, m;
   int z = 1;
   while ( scanf("%d%d",&n,&m) != EOF )
   {
      if ( n == 0 && m == 0 ) break;
      if ( z != 1 ) printf("\n");
      printf("Field #%d: \n", z);
      z++;
      if ( n*m != 0 )
      {
         REP (i, n+2)
            REP (j, m+2)
               A[i][j] = 0;
         FOR (i, 1, n+1)
            scanf("%s",A[i]+1);
         FOR (i, 1, n+1)
            FOR(j, 1, m+1)
               ANS[i][j] = count(i, j);
         FOR (i, 1, n+1)
         {
            FOR(j, 1, m+1)
               printf("%c", ANS[i][j]+'0');
            if ( m != 0 ) printf("\n");
         }
      }
   }
   return 0;
}


What is going on? I believe that i don't have any extra lines but I still get PE. Or does ( m != 0 ) printf("\n"); count as a new line?
sajnt
New poster
 
Posts: 2
Joined: Fri Jun 18, 2010 10:03 pm

Re: 10189 - Minesweeper

Postby fzafarani » Mon Jul 19, 2010 10:54 pm

Can anyone help me why my code gets WA? :|
Code: Select all
#include <iostream>
using namespace std;

int main(void) {
   //   ofstream cout("out.txt");
   int m, n;
   int fl = 1;
   while (cin >> m >> n) {
      char game[120][120];
      char res[120][120];
      if (m == 0 && n == 0)
         break;
      for (int i = 0; i < m; i++)
         for (int j = 0; j < n; j++)
            cin >> game[i][j];
      for (int i = 0; i < m; i++)
         for (int j = 0; j < n; j++) {
            if (game[i][j] == '*')
               res[i][j] = '*';
            else {
               int cnt = 0;
               if (j + 1 < n)
                  if (game[i][j + 1] == '*')
                     cnt++;
               if (i + 1 < m && j + 1 < n)
                  if (game[i + 1][j + 1] == '*')
                     cnt++;
               if (i + 1 < m)
                  if (game[i + 1][j] == '*')
                     cnt++;
               if (i + 1 < m && j - 1 >= 0)
                  if (game[i + 1][j - 1] == '*')
                     cnt++;
               if (j - 1 >= 0)
                  if (game[i][j - 1] == '*')
                     cnt++;
               if (i - 1 >= 0 && j - 1 >= 0)
                  if (game[i - 1][j - 1] == '*')
                     cnt++;
               if (i - 1 >= 0)
                  if (game[i - 1][j] == '*')
                     cnt++;
               if (i - 1 >= 0 && j + 1 < n)
                  if (game[i - 1][j + 1] == '*')
                     cnt++;
               res[i][j] = cnt + '0';
            }
         }
      if (fl > 1)
         cout << endl << endl;
      cout << "Field #" << fl << ":" << endl;
      fl++;
      for (int i = 0; i < m; i++) {
         for (int j = 0; j < n; j++)
            cout << res[i][j];
         if (i != m - 1)
            cout << endl;
      }
   }
   return 0;
}

fzafarani
New poster
 
Posts: 1
Joined: Mon Jul 19, 2010 10:50 pm

Re: 10189 - Minesweeper

Postby acoconut » Mon Jul 26, 2010 2:03 pm

Can someone help me? I keep getting wrong answer and I can't figure out why! :-/ Tricky cases to test would be appreciated too.

Code: Select all
#include <iostream>

class cas{
   bool mine;
   public:
   cas ();
   bool get_mine();
   void set_mine(bool);
};

cas::cas (){
   mine = false;
}

bool cas::get_mine (){
   return mine;
}

void cas::set_mine (bool b){
   mine = b;
}

int main(){
   unsigned int fields=0;
   int n = 0;
   int m = 0;
   char a;
   bool b;
   unsigned int cont = 0;
   std::cin>>n;
   std::cin>>m;
   while (n !=0 || m != 0){
      fields++;
      std::cout<<"Field #"<< fields<< std::endl;
      cas matrix[n][m];

      for (int i=0; i <n; i++){
         for (int j = 0; j < m; j++){
            std::cin >> a;
            if (a == '*'){
               matrix[i][j].set_mine(true);
            }
         }
      }
      
      for (int i=0; i<n; i++){
         for (int j=0; j<m; j++){
            if (matrix[i][j].get_mine()){
               std::cout<<"*";
            }else{
               //check
               cont = 0;
               if (i == 0 && j==0 && i == n-1 && j == m-1) {
                  cont = 0;
               }else if (i == 0 && j == 0){
                  //esquina arriba izquierda
                  if (matrix[i][j+1].get_mine()){
                     cont++;
                  }
                  if (matrix[i+1][j].get_mine()){
                     cont++;
                  }
                  if (matrix[i+1][j+1].get_mine()){
                     cont++;
                  }
               }else if (i == 0 && j == m-1){
                  //esquina arriba derecha
                  if (matrix[i+1][j].get_mine()){
                     cont++;
                  }
                  if (matrix[i+1][j-1].get_mine()) {
                     cont++;
                  }
                  if (matrix[i][j-1].get_mine()){
                     cont++;
                  }
               }else if (i == n-1 && j == 0){
                  //esquina abajo izquierda
                  if (matrix[i][j+1].get_mine()){
                     cont++;
                  }
                  if (matrix[i-1][j].get_mine()) {
                     cont++;
                  }
                  if (matrix[i-1][j+1].get_mine()){
                     cont++;
                  }
               }else if (i == n-1 && j == m-1){
                  //esquina abajo derecha
                  if (matrix[i-1][j].get_mine()){
                     cont++;
                  }
                  if (matrix[i-1][j-1].get_mine()) {
                     cont++;
                  }
                  if (matrix[i][j-1].get_mine()){
                     cont++;
                  }
               }else if (i == 0 && j != 0 && j != m-1){
                  //linea de arriba, pero no esquinas
                  if (matrix[i][j+1].get_mine()){
                     cont++;
                  }
                  if (matrix[i][j-1].get_mine()) {
                     cont++;
                  }
                  if (matrix[i+1][j].get_mine()){
                     cont++;
                  }
                  if (matrix[i+1][j-1].get_mine()){
                     cont++;
                  }
                  if (matrix[i+1][j+1].get_mine()){
                     cont++;
                  }
               }else if (i == n-1 && j != 0 && j != m-1){
                  //linea de abajo, pero no esquinas
                  if (matrix[i][j+1].get_mine()){
                     cont++;
                  }
                  if (matrix[i][j-1].get_mine()) {
                     cont++;
                  }
                  if (matrix[i-1][j].get_mine()){
                     cont++;
                  }
                  if (matrix[i-1][j-1].get_mine()){
                     cont++;
                  }
                  if (matrix[i-1][j+1].get_mine()){
                     cont++;
                  }
               }else if (i != 0 && i != n-1 && j == 0){
                  //columna izquierda pero no esquinas
                  if (matrix[i-1][j].get_mine()){
                     cont++;
                  }
                  if (matrix[i+1][j].get_mine()) {
                     cont++;
                  }
                  if (matrix[i+1][j+1].get_mine()){
                     cont++;
                  }
                  if (matrix[i][j+1].get_mine()){
                     cont++;
                  }
                  if (matrix[i-1][j+1].get_mine()){
                     cont++;
                  }
               }else if (i != 0 && i != n-1 && j == m-1){
                  //columna derecha pero no esquinas
                  if (matrix[i-1][j].get_mine()){
                     cont++;
                  }
                  if (matrix[i+1][j].get_mine()) {
                     cont++;
                  }
                  if (matrix[i+1][j-1].get_mine()){
                     cont++;
                  }
                  if (matrix[i][j-1].get_mine()){
                     cont++;
                  }
                  if (matrix[i-1][j-1].get_mine()){
                     cont++;
                  }
               }else{
                  //celda central
                  if (matrix[i-1][j-1].get_mine()){
                     cont++;
                  }
                  if (matrix[i-1][j].get_mine()) {
                     cont++;
                  }
                  if (matrix[i-1][j+1].get_mine()){
                     cont++;
                  }
                  if (matrix[i][j-1].get_mine()){
                     cont++;
                  }
                  if (matrix[i][j+1].get_mine()){
                     cont++;
                  }
                  if (matrix[i+1][j-1].get_mine()){
                     cont++;
                  }
                  if (matrix[i+1][j].get_mine()){
                     cont++;
                  }
                  if (matrix[i+1][j+1].get_mine()){
                     cont++;
                  }
               }
               std::cout<<cont;
            }   
         }
         std::cout<<std::endl;
      }
   std::cout<<std::endl;
   std::cin>>n;
   std::cin>>m;

   }
}
acoconut
New poster
 
Posts: 1
Joined: Mon Jul 26, 2010 1:02 pm

Re: 10189 - Minesweeper

Postby hosnayen » Wed Aug 04, 2010 7:42 pm

i m getting wrong answer :( . can any1 help me :( , i dont understand why :(. here is my code :-

/*
Author : Hosnayen Alam Siddiquee.
University of Science & Technology Chittagong (USTC)
CSE- 11th Batch
E-mail: hosnayen_alam@yahoo.com
Bangladesh Date: 30/07/2010
*/

#include<stdio.h>
#include<iostream>
#include<string>

using namespace std;

int main()
{
int i,j,n,m,count=0,kase=0;

//freopen("10189_in.txt","r",stdin);

while(cin >> n >>m)
{
if(n==0 && m==0) break;

char r[110][110];
int sum[110][110]={0};

if(kase++){
cout<<endl;
}

for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{

cin>> r [i] [j] ;
}
}


for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
if (r[i] [j]=='*')
{
sum [i] [j+1]++;
sum [i+1] [j+1]++;
sum [i+1] [j]++;
sum [i+1] [j-1]++;
sum [i] [j-1]++;
sum [i-1] [j-1]++;
sum [i-1] [j]++;
sum [i-1] [j+1]++;
}

}
}

cout<<"Field #"<<++count<<":"<< endl;

for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
if(r [i] [j] == '*')
{
cout<< "*";
}
else
cout<<sum[i][j];

}

cout<<endl;
}
}



return 0;
}
hosnayen
New poster
 
Posts: 4
Joined: Mon Dec 28, 2009 8:41 pm

Re: 10189 - Minesweeper

Postby hosnayen » Wed Aug 04, 2010 7:42 pm

i m getting wrong answer :( . can any1 help me :( , i dont understand why :(. here is my code :-

/*
Author : Hosnayen Alam Siddiquee.
University of Science & Technology Chittagong (USTC)
CSE- 11th Batch
E-mail: hosnayen_alam@yahoo.com
Bangladesh Date: 30/07/2010
*/

#include<stdio.h>
#include<iostream>
#include<string>

using namespace std;

int main()
{
int i,j,n,m,count=0,kase=0;

//freopen("10189_in.txt","r",stdin);

while(cin >> n >>m)
{
if(n==0 && m==0) break;

char r[110][110];
int sum[110][110]={0};

if(kase++){
cout<<endl;
}

for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{

cin>> r [i] [j] ;
}
}


for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
if (r[i] [j]=='*')
{
sum [i] [j+1]++;
sum [i+1] [j+1]++;
sum [i+1] [j]++;
sum [i+1] [j-1]++;
sum [i] [j-1]++;
sum [i-1] [j-1]++;
sum [i-1] [j]++;
sum [i-1] [j+1]++;
}

}
}

cout<<"Field #"<<++count<<":"<< endl;

for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
if(r [i] [j] == '*')
{
cout<< "*";
}
else
cout<<sum[i][j];

}

cout<<endl;
}
}



return 0;
}
hosnayen
New poster
 
Posts: 4
Joined: Mon Dec 28, 2009 8:41 pm

Re: 10189 - Minesweeper

Postby fkrafi » Wed Oct 06, 2010 8:00 pm

WHy WA????
Code: Select all
Solved...
Last edited by fkrafi on Tue Mar 01, 2011 2:44 pm, edited 1 time in total.
fkrafi
New poster
 
Posts: 13
Joined: Wed Sep 15, 2010 1:36 pm

Re: 10189 - Minesweeper

Postby harry_falcon » Wed Oct 27, 2010 4:23 am

can someone help me?
I got WA using this code:

#include <iostream>

using namespace std;

char field[102][102];

int scanArea(int m, int n){
int count = 0;
for(int i = m-1; i <= m+1; i++){
for(int j = n-1; j <= n+1; j++){
if(field[i][j] == '*') count++;
}
}
return count;
}

int main()
{
int m = 1;
int n = 1;
int count = 0;
int i;
int j;
while(cin >> m >> n){
if(m > 0 && m <= 100 && n > 0 && n <= 100)
{
i=1;
while(i <= m){
j=1;
while(j <= n){
cin >> field[i][j];
j++;
}i++;
}count++;
cout << "Field #" << count << ":" << endl;
i=1;
while(i <= m){
j=1;
while(j <= n){
if(field[i][j] == '.') cout << scanArea(i,j);
else cout << '*';
j++;
}i++;
cout << endl;
}
}
}return 0;
}
harry_falcon
New poster
 
Posts: 1
Joined: Wed Oct 27, 2010 3:35 am

Re: 10189 - Minesweeper

Postby live_lie » Tue Nov 30, 2010 12:03 am

i got AC. you have print a single blank line after all output. but for 0 0 make sure that your program print no blank line.
and be carefull for low inputs. like 1 1 ,2 2or 3 3.
if you chk by loop .be sure that index never over load the value 0f n or m.
live_lie
New poster
 
Posts: 19
Joined: Mon Nov 29, 2010 11:50 pm

Re: 10189 - Minesweeper

Postby leonardoferrari » Mon Mar 14, 2011 5:01 am

Keep getting WA, don't know what to do.
My Outputs are all right !
Code: Select all
nevermind, got AC.



Thanks in advance !

P.S -> when doing a counter to the field, dont forget to do and endl only at the first output. Aka if(counter) cout << endl;
leonardoferrari
New poster
 
Posts: 5
Joined: Mon Mar 14, 2011 4:59 am

Re: 10189 - Minesweeper

Postby drahar » Sun Mar 20, 2011 6:30 pm

Hi, guys.
I can't figure out what i'm doing wrong. I formatted the output as it should be - one line between fields, no new line after the last field.
In all my test everything looks okay, but i still get WA. I would really appreciate any help :) Here's my code:
Code: Select all
#include <fcntl.h>
#include <iostream>
#include <fstream>
#include <stdio.h>

using namespace std;

void updateField(int **mineField, int posY, int posX, int rows, int columns){

    mineField[posY][posX] = -9;
    //North
    if((posY - 1) >= 0)
        mineField[posY-1][posX]++;

    //South
    if((posY + 1) < rows)
        mineField[posY + 1][posX]++;

    //West
    if((posX - 1) >= 0)
        mineField[posY][posX - 1]++;

    //East
    if((posX + 1) < columns)
        mineField[posY][posX + 1]++;

    //NorthWest
    if(((posY - 1) >=0) && ((posX - 1) >= 0))
        mineField[posY - 1][posX - 1]++;

    //SouthWest
    if(((posY + 1) < rows) && ((posX - 1) >= 0))
        mineField[posY + 1][posX - 1]++;

    //NorthEast
    if(((posY - 1) >=0) && ((posX + 1) < columns))
        mineField[posY - 1][posX + 1]++;

    //SouthEast
    if(((posY + 1) < rows) && ((posX + 1) < columns))
        mineField[posY + 1][posX + 1]++;
}


int main(int argc, char** argv) {

#ifndef ONLINE_JUDGE
    close (0) ; open ("test.txt", O_RDONLY);
    close (1) ; open ("result.txt", O_WRONLY | O_CREAT, 0600);
#endif

    int field = 1;
    int rows, columns;
    while (cin >> rows >> columns){

        //check for end of input
        if (rows == 0 || columns == 0){
            //cout << "break";
            break;
        }
        if(field > 1)
            cout << endl << endl;

        //Dynamic field declaration and initialization
        int **mineField;
        mineField = new int*[rows];
        for (int i = 0; i < rows; i++){
            mineField[i] = new int[columns];
        }
        for(int i = 0; i < rows; i++)
            for(int j = 0; j < columns; j++)
                mineField[i][j] = 0;

        //main iteration loop
        for (int i = 0; i < rows; i++){
            string line;
            cin >> line;
            //cout << "echo: " << line << endl;

            for (int j = 0; j < columns; j++){
                if (line[j] == '*')
                    updateField(mineField, i,j,rows,columns);
            }
        }


        //print out results
        cout << "Field #" << field << ":" << endl;
        for(int i = 0; i < rows; i++){
            for(int j = 0; j < columns; j++)
                if(mineField[i][j] < 0)
                    cout << '*';
                else
                    cout << mineField[i][j];
            if (i != (rows -1))
                cout << endl;
        }
        field++;

        //Dymanic array memory release
        for (int i = 0; i < rows; i++){
            delete[] mineField[i];
        }
        delete[] mineField;
        mineField = 0;
    }
    return 0;
}
drahar
New poster
 
Posts: 1
Joined: Sun Mar 20, 2011 6:26 pm

Re: 10189 - Minesweeper

Postby eyefinity » Mon Apr 18, 2011 6:31 pm

Can someone help me with this code.. am getting WA....
Code: Select all
#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
   //freopen("input.txt", "r+", stdin);
   //freopen("output.txt", "w+", stdout);

   long row, column, cases=1;
   
   while (true)
   {
      cin >> row >> column;
      if(row==0 && column ==0) break;

      char array[150][150];
      int ans[152][152]={0};

      for (int i=0; i < row; i++)
         for (int j=0; j < column; j++)
         {
            cin >> array[i][j];
            if(array[i][j]=='*') ans[i+1][j+1]=1;
         }
      for (int i=0; i < row; i++)
      {
         for (int j=0; j < column; j++)
         {
            if(array[i][j]=='.')
            {
               array[i][j] = ans[i][j+1]+ans[i+2][j+1]+ans[i+1][j]+ans[i+1][j+2]
               +ans[i][j]+ans[i+2][j+2]+ans[i+2][j]+ans[i][j+2] + 48;
            }
         }
      }
      cout << "Field #" << cases << ":" << endl ;
      for (int i=0; i < row; i++)
      {
         for (int j=0; j < column; j++)
         {
            cout << array[i][j];
         }
         cout << endl;
      }
      cases++;
      cout << endl;
   }

   return 0;
}
eyefinity
New poster
 
Posts: 1
Joined: Mon Apr 18, 2011 6:27 pm

Re: 10189 - Minesweeper

Postby muctadir.dinar » Tue Apr 19, 2011 10:30 am

getting wa with code below,
Code: Select all
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

int main()
{
    long int row, column;
    int fieldCount = 0;

    while (scanf("%ld %ld", &row, &column)!=EOF)
    {
        if (row == 0 && column == 0)
        {
            break;
        }

        char input[row+100][column+100];

        getchar();

        if (fieldCount!=0)
        {
            printf("\n");
        }

        fieldCount++;

        for (int r = 0; r<row; r++)
        {
            gets(input[r]);
        }
        printf("Field #%d:\n", fieldCount);


        char result[row+100][column+100];
        for (int r = 0; r<row; r++)
        {
            int c;
            for (c = 0; c<column; c++)
            {
                int mineCount = 0;

                if (input[r][c]!='*')
                {

                    if (input[r][c+1] == '*')
                    {
                        mineCount++;
                    }

                    if (input[r][c-1] == '*')
                    {
                        mineCount++;
                    }

                    if (input[r+1][c] == '*')
                    {
                        mineCount++;
                    }

                    if (input[r+1][c+1] == '*')
                    {
                        mineCount++;
                    }

                    if (input[r+1][c-1] == '*')
                    {
                        mineCount++;
                    }

                    if (input[r-1][c] == '*')
                    {
                        mineCount++;
                    }

                    if (input[r-1][c+1] == '*')
                    {
                        mineCount++;
                    }

                    if (input[r-1][c-1] == '*')
                    {
                        mineCount++;
                    }

                    result[r][c] = 48+mineCount;

                }
                else
                {
                    result[r][c] = '*';
                }
            }
            result[r][c] = NULL;
        }

        for (int i = 0; i<row; i++)
        {
            for (int j = 0; j<column; j++)
            {
                printf("%c", result[i][j]);
            }
            printf("\n");
        }
    }

    return 0;
}



You are the one, who can make a difference...
muctadir.dinar
New poster
 
Posts: 4
Joined: Sat Apr 16, 2011 10:04 pm
Location: IIT, DU

PreviousNext

Return to Volume CI

Who is online

Users browsing this forum: No registered users and 1 guest