10189 - Minesweeper

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

Moderator: Board moderators

mooseelkdog
New poster
Posts: 18
Joined: Fri Oct 10, 2003 8:46 am
Location: Airway Heights

Post by mooseelkdog »

Can anyone tell me what might cause the presentation error in this code?

Code: Select all

#include <iostream>
#include <cstring>
#include <cassert>

using namespace std;

class CMines
{
	public:

		CMines();
		CMines(char**, int, int);
		~CMines();
		void setRows(int);
		void setCols(int);
		void setBoard(char**);
		int getRows() const;
		int getCols() const;
		int** getBoard() const;

	private:

		int ** board;
		int rows, cols;

}; // end class CMines header

ostream &operator<< (ostream &, const CMines &);
char * StrDup(const char*);

int main()
{
	int l_rows, l_cols, count = 0;
	char temp[255], ** input;
	CMines* game;

	cin >> l_rows;
	cin.get();
	cin >> l_cols;
	cin.get();

	while(l_rows != 0 || l_cols != 0)
	{
		input = new char*[l_rows];

		for(int x = 0; x < l_rows; x++)
			input[x] = new char[l_cols];

		for(int x = 0; x < l_rows; x++)
		{
			cin.getline(temp, 255);
			input[x] = StrDup(temp);

		} // end for

		game = new CMines(input, l_rows, l_cols);

		cout << "Field #" << ++count << ":\n" << *game << endl;

		for(int x = 0; x < l_rows; x++)
			delete [] input[x];

		delete [] input;

		input = NULL;

		cin >> l_rows;
		cin.get();
		cin >> l_cols;
		cin.get();

	} // end while

	return 0;

} // end main()

CMines::CMines()
{
	board = NULL;

} // end default CMines constructor

CMines::CMines(char** in, int r, int c)
{
	setRows(r);
	setCols(c);
	setBoard(in);

} // end explicit CMines constructor

CMines::~CMines()
{
	for(int x = 0; x < getRows(); x++)
		delete [] board[x];

	delete [] board;

	board = NULL;

} // end CMines DESTRUCTOR

void CMines::setRows(int r)
{
	rows = r;

} // end setRows()

void CMines::setCols(int c)
{
	cols = c;

} // end setCols()

void CMines::setBoard(char ** in)
{
	int up, down, left, right;
	up = left = -1;
	down = right = 1;

	board = new int*[getRows()];

	for(int x = 0; x < getRows(); x++)
		board[x] = new int[getCols()];

	for(int x = 0; x < getRows(); x++)
		for(int y = 0; y < getCols(); y++)
			(in[x][y] == '*') ? board[x][y] = -1 : board[x][y] = 0;

	for(int x = 0; x < getRows(); x++)
	{
		for(int y = 0; y < getCols(); y++)
		{
			if(board[x][y] == -1)
			{
				if(x + up > -1 && y + left > -1)
					if(board[x + up][y + left] != -1)
						board[x + up][y + left]++;
				if(y + left > -1)
					if(board[x][y + left] != -1)
						board[x][y + left]++;
				if(x + up > -1 && y + right < getCols())
					if(board[x + up][y + right] != -1)
						board[x + up][y + right]++;
				if(x + up > -1)
					if(board[x + up][y] != -1)
						board[x + up][y]++;
				if(x + down < getRows() && y + right < getCols())
					if(board[x + down][y + right] != -1)
						board[x + down][y + right]++;
				if(y + right < getCols())
					if(board[x][y + right] != -1)
						board[x][y + right]++;
				if(x + down < getRows() && y + left > -1)
					if(board[x + down][y + left] != -1)
						board[x + down][y + left]++;
				if(x + down < getRows())
					if(board[x + down][y] != -1)
						board[x + down][y]++;

			} // end if

		} // end for

	} // end for

} // end setBoard()

int CMines::getRows() const { return rows; } // end getRows()
int CMines::getCols() const { return cols; } // end getCols()
int** CMines::getBoard() const { return board; } // end getBoard()

ostream &operator<< (ostream & out, const CMines & A)
{
	for(int x = 0; x < A.getRows(); x++)
	{
		for(int y = 0; y < A.getCols(); y++)
			(A.getBoard()[x][y] == -1) ? out << "*" : out << A.getBoard()[x][y];

		out << endl;

	} // end for

	return out;

} // end ostream operator<< overload

char * StrDup(const char *in)
{
	char * copy = new char [1 + strlen(in)];
	assert (copy != NULL);
	strcpy (copy, in);

	return copy;

} // end StrDup()

lky
New poster
Posts: 21
Joined: Fri Dec 05, 2003 5:59 pm
Contact:

10189 WA

Post by lky »

any critical test data for this Q?
pls help
wD
New poster
Posts: 2
Joined: Mon Dec 22, 2003 12:46 am
Location: Portugal - Aveiro
Contact:

ACMIO avaialable in acm@uva?

Post by wD »

I'm new to this board, but i've fully searched the entire board and i didn't find anything that could answer to my question.
I've tried to submit the problem 10189 in java with ACMIO but it gives to me a "compilation error"
So i wonder, is ACMIO implemented in the judge evaluation?
here is the code:
[java]import java.io.*;
import java.util.*;

class Main {
public static void main(String[] args) {
Main mines = new Main();
mines.start();
}

void start() {
int nLines=0, nColumns=0, counter = 0;
ACMIO stdin = ACMIO.getStdin();

nLines = stdin.intRead();
nColumns = stdin.intRead();
while(nLines != 0 && nColumns != 0) {
if(counter != 0) System.out.println();
counter++;
int map[][] = new int[nLines][nColumns];

for(int i=0; i<nLines; i++)
for(int j=0; j<nColumns; j++) {
char val = stdin.charRead();
if(val == '*') map[j] = -1;
else map[j] = 0;
}

System.out.println("Field #"+counter+":");

calc(map,nLines,nColumns);
for(int i=0; i<nLines; i++) {
for(int j=0; j<nColumns; j++) {
if(map[j] != -1)
System.out.print(map[j]);
else System.out.print('*');
}
System.out.println();
}
nLines = stdin.intRead();
nColumns = stdin.intRead();
}
}

int isAst(int[][] map,int i,int j) {
if(map[j] == -1) return 1;
else return 0;
}

void calc(int[][] map, int nLines, int nColumns) {
int nAst=0;
for(int i=0; i<nLines; i++)
for(int j=0; j<nColumns; j++) {
nAst=0;
if(map[j] != -1) {
if(i-1 >= 0 && j-1 >= 0) nAst += isAst(map,i-1,j-1);
if(i-1 >= 0 && j >= 0) nAst += isAst(map,i-1,j);
if(i-1 >= 0 && j+1 < nColumns) nAst += isAst(map,i-1,j+1);

if(i >= 0 && j-1 >= 0) nAst += isAst(map,i,j-1);
if(i >= 0 && j >= 0) nAst += isAst(map,i,j);
if(i >= 0 && j+1 < nColumns) nAst += isAst(map,i,j+1);

if(i+1 < nLines && j-1 >= 0) nAst += isAst(map,i+1,j-1);
if(i+1 < nLines && j >= 0) nAst += isAst(map,i+1,j);
if(i+1 < nLines && j+1 < nColumns) nAst += isAst(map,i+1,j+1);
map[j] = nAst;
}
}

}

void printMap(int[][] map,int nLines, int nColumns) {
for(int i=0; i<nLines; i++) {
for(int j=0; j<nColumns; j++)
System.out.print(map[j]);
System.out.println();
}
}
}
[/java]
The code is kind ugly, but i think it's working :)
Thank you for the possible replies!
"May God be between you and Evil, in every single path you have to walk"
Spike
New poster
Posts: 29
Joined: Mon Mar 18, 2002 2:00 am
Location: Washington State
Contact:

Post by Spike »

ACMIO is not a standard java class. In fact, I'd never heard of it until I looked it up on google.

UVA is very picky about the classes that they support, and very behind the times. I've written some methods that do similar things to ACMIO ( check this board under "[JAVA] Useful methods to save time" ), and it looks like I can add a few more of those things.

In addition, I'll be adding a library of common algorithms in Java in the upcoming months.
epidemyk
New poster
Posts: 3
Joined: Tue Feb 03, 2004 7:01 am

10189 Minesweeper - Compile Error

Post by epidemyk »

I'm not sure why this won't compile... Any advice:

[c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#define MAXSIZE 100

struct {
int bombs;
int count;
} map[MAXSIZE][MAXSIZE];

int main(void)
{
int mx, my;
int i, j;
int count = 1;

while(scanf("%d%d", &mx, &my) != EOF)
{
if ( (mx == 0) && (my == 0) )
{
return(0);
}

printf("Field #%d:\n", count);
char board[mx][my];

for(i=0; i < mx; i++)
scanf("%s", board);

for(i=1; i<mx-1; i++)
{
for(j=1; j < my-1; j++)
{
if (board[j] == '*') /* Inside of board */
{ /* No edges or corners */
map[j].bombs = 1;
map[i-1][j-1].count++;
map[i-1][j ].count++;
map[i-1][j+1].count++;
map[j-1].count++;
map[j+1].count++;
map[i+1][j-1].count++;
map[i+1][j ].count++;
map[i+1][j+1].count++;
}
}
}

if (board[0][0] == '*') /* Top Left */
{
map[0][0].bombs =1; map[0][1].count++;
map[1][0].count++; map[1][1].count++;
}
if (board[0][my-1] == '*') /* Top Right */
{
map[0][my-1].bombs = 1; map[0][my-2].count++;
map[1][my-2].count++; map[1][my-1].count++;
}
if(board[mx-1][my-1] == '*') /* Bottom Right */
{
map[mx-1][my-1].bombs = 1; map[mx-2][my-1].count++;
map[mx-2][my-2].count++; map[mx-1][my-2].count++;
}
if(board[mx-1][0] == '*') /* Bottom Left */
{
map[mx-1][0].bombs = 1; map[mx-2][0].count++;
map[mx-2][1].count++; map[mx-1][1].count++;
}

for(i=1; i < mx-1; i++)
{
if(board[0] == '*') /* Top Edge */
{
map[0].bombs=1; map[0][i-1].count++;
map[1][i-1].count++; map[1].count++;
map[1][i+1].count++; map[0][i+1].count++;
}
if(board[mx-1] == '*') /* Bottom Edge */
{
map[mx-1].bombs=1; map[mx-1][i-1].count++;
map[mx-2][i-1].count++; map[mx-2][i ].count++;
map[mx-2][i+1].count++; map[mx-1][i+1].count++;
}
}
for(i=1; i < my-1; i++)
{
if(board[i][0] == '*') /* Left Edge */
{
map[i ][0].bombs=1; map[i-1][0 ].count++;
map[i-1][1].count++; map[i ][1 ].count++;
map[i+1][0].count++; map[i+1][1 ].count++;
}
if(board[i][my-1] == '*') /* Right Edge */
{
map[i ][my-1].bombs=1; map[i-1][my-1].count++;
map[i-1][my-2].count++; map[i ][my-2].count++;
map[i+1][my-2].count++; map[i ][my-1].count++;
}
}
for(i = 0; i < mx; i++) /* Print board */
{
for(j=0; j < my; j++)
{
if (map[i][j].bombs == 1)
putchar('*');
else if (map[i][j].count == 0)
putchar('.');
else
printf("%d", map[i][j].count);
}
printf("\n");
}
printf("\n");
count++;

for(i=0; i<MAXSIZE; i++)
for(j=0; j<MAXSIZE; j++)
{
map[i][j].count = 0;
map[i][j].bombs = 0;
}
}
return 0;
}
[/c]

Here are the compiler error messages:

02268457_24.c: In function `main':
02268457_24.c:28: parse error before `char'
02268457_24.c:31: `board' undeclared (first use in this function)
02268457_24.c:31: (Each undeclared identifier is reported only once
02268457_24.c:31: for each function it appears in.)

--
epidemyk
New poster
Posts: 3
Joined: Tue Feb 03, 2004 7:01 am

Nevermind

Post by epidemyk »

Nevermind, I figured it out...
jhonny_yang
New poster
Posts: 22
Joined: Fri Jan 17, 2003 8:24 am

Why Wrong ???

Post by jhonny_yang »

[c]
#include <stdio.h>

void Calculateit(int arr[110][110],int maxx,int maxy)
{
int x,y;
for (y=0;y<maxy;y++){
for (x=0;x<maxx;x++){
if (arr[y][x]=='*'){
if (y>0){
if (arr[y-1][x]!='*'){
arr[y-1][x]++;
}
}
if (x>0){
if (arr[y][x-1]!='*'){
arr[y][x-1]++;
}
}
if (x<=maxx-2){
if (arr[y][x+1]!='*'){
arr[y][x+1]++;
}
}
if (y<=maxy-2){
if (arr[y+1][x]!='*'){
arr[y+1][x]++;
}
}
if (x>0&&y>0){
if (arr[y-1][x-1]!='*'){
arr[y-1][x-1]++;
}
}
if (x<=maxx-2&&y>0){
if (arr[y-1][x+1]!='*'){
arr[y-1][x+1]++;
}
}
if (x>0&&y<=maxy-2){
if (arr[y+1][x-1]!='*'){
arr[y+1][x-1]++;
}
}
if (x<=maxx-2&&y<=maxy-2){
if (arr[y+1][x+1]!='*'){
arr[y+1][x+1]++;
}
}
}
}
}
}

void Printit(int count,int arr[110][110],int maxx,int maxy)
{
int x,y;
printf("Field #%d:\n",count);
for (y=0;y<maxy;y++){
for (x=0;x<maxx;x++){
if (arr[y][x]=='*')printf("*");
else printf("%d",arr[y][x]);
}
if (y<=maxy-2)printf("\n");
}
}

void main()
{
int arr[110][110],m,n,x,y,i,count;
char buffer[110];

count=1;
while (scanf("%d %d\n",&n,&m)!=EOF){
if (n==0 && m==0)break;
for (y=0;y<n;y++){
gets(buffer);
i=0;x=0;
while (buffer){
if (buffer=='*')arr[y][x]='*';
else if (buffer=='.')arr[y][x]=0;
++i;++x;
}
}
if (count>1)printf("\n\n");
Calculateit(arr,m,n);
Printit(count,arr,m,n);
count++;
}
}
[/c]

Why PE ???
Julien Cornebise
Experienced poster
Posts: 145
Joined: Sat Feb 23, 2002 2:00 am
Location: Paris, France
Contact:

Post by Julien Cornebise »

Read above about my mind concerning PE :wink:
Nyst
New poster
Posts: 2
Joined: Tue Mar 02, 2004 1:00 pm

10189 WA (JAVA)

Post by Nyst »

Can someone please advise me on the following java code? I ran it on my system(winxp) and tested the output. It is correct(I think), but I keep getting WA.

[java]
class Main {

public static void main(String args[]) {
Main myWork = new Main();
myWork.begin();
}


void begin() {
byte mf[][] = null;
int v, h, j, fieldCount;
String input;
StringTokenizer data;
fieldCount = 0;
v = 0;
h = 0;

while((input = Main.readLn(255)) != null) {
if((input.charAt(0) != '*') && (input.charAt(0) != '.')) {
data = new StringTokenizer(input);
v = Integer.parseInt(data.nextToken());
h = Integer.parseInt(data.nextToken());
if(0 == v && 0 == h) {
break;
}
else if(v == 0 || h ==0){
fieldCount++;
System.out.println("Field #" + fieldCount +":");
System.out.println("");
}
else {
mf = new byte[v+10][h+10];
}
}
else if(v != 0 && h != 0 && mf != null) { // valid field

j = 1; //vertical counter

do {

for(int i = 1; i <= h; i++) {
if(input.charAt(i-1) == '*') { //if it is a mine increase the surrounding values by 1
mf[j-1][i-1]++;
mf[j-1]++;
mf[j-1][i+1]++;
mf[j][i-1]++;
mf[j] = -99; //ensures that a mine value stays negative
mf[j][i+1]++;
mf[j+1][i-1]++;
mf[j+1]++;
mf[j+1][i+1]++;
}
}

j++; //increase the vertical counter
if(j>v)
break;

}while((input = Main.readLn(255)) != null);

fieldCount++;
System.out.println("Field #" + fieldCount +":");

for(int a = 1; a <= v; a++) {
for(int b = 1; b <= h; b++) {
if(mf[a] < 0)
System.out.print("*");
else
System.out.print(mf[a]);
}
System.out.println(""); //end of line, start next line
}
System.out.println(""); //end of field, print an extra line

mf = null;
v = 0;
h = 0;
} //end else if
} //end while
}


static String readLn (int maxLg) // utility function to read from stdin
{
byte lin[] = new byte [maxLg];
int lg = 0, car = -1;
String line = "";

try
{
while (lg < maxLg)
{
car = System.in.read();
if ((car < 0) || (car == '\n')) break;
lin [lg++] += car;
}
}
catch (IOException e)
{
return (null);
}

if((car < 0) && (lg == 0)) return (null); // eof

return (new String (lin, 0, lg));
}
}[/java]
Nyst
New poster
Posts: 2
Joined: Tue Mar 02, 2004 1:00 pm

Post by Nyst »

Never mind...I recode it in C++ and it got AC. I'm not going to use Java for the problems until they decide to use standard Java libraries and compilers... :roll:
midra
Experienced poster
Posts: 119
Joined: Fri Feb 13, 2004 7:20 am
Contact:

10189...WA. I am so confused with simple task

Post by midra »

Hi!
I get WA in this problem
Here is my code:
[c]
#include <stdio.h>

int main()
{
int t=0;
int minas[105][105];
int n,m;
int i,x;
char c[105][105];
int z;
empieza:
t++;
scanf("%d %d", &n, &m);

if (n==0 && m==0)
return 0;
for (i=1; i<=n+1; i++)
for (x=1; x<=m+1; x++)
minas[x]=0;

for (i=1; i<=n; i++)
for (x=1; x<=m; x++)
{
scanf("%c", &c[x]);
if (c[x]=='\n')
x--;
}

for (i=1; i<=n; i++)
for (x=1; x<=m; x++)
{
if (c[x]=='.')
{
if (c[x+1]=='*')
minas[x]++;
if (c[x-1]=='*')
minas[x]++;
if (c[i+1][x]=='*')
minas[x]++;
if (c[i-1][x]=='*')
minas[x]++;
if (c[i+1][x+1]=='*')
minas[i][x]++;
if (c[i+1][x-1]=='*')
minas[i][x]++;
if (c[i-1][x+1]=='*')
minas[i][x]++;
if (c[i-1][x-1]=='*')
minas[i][x]++;
}
else if (c[i][x]=='*')
minas[i][x]=15;
}

printf ("Field #%d:\n",t);
for (i=1; i<=n; i++)
{
for (x=1; x<=m; x++)
{
if (minas[i][x]==15)
printf("*");
else
printf("%d", minas[i][x]);
}
printf("\n");
}
printf("\n");
goto empieza;
}
[/c]

First I think that it would be AC, maybe PE, but when I submit it I got WA
I think it's the way I must output the data, but I don't know how to do this part. If someone have understand me and could give me an idea I would appreciate...
(sorry for my ugly english).

Thanks for reading! :D
sohel
Guru
Posts: 856
Joined: Thu Jan 30, 2003 5:50 am
Location: New York

minor mistake

Post by sohel »

Hello Midra,

I have checked your code and found a minor mistake.
- you forgot to flush the char array before processing consecutive input.

Take a look at the following example....

For the input
[c]
2 2
**
**
1 1
.
[/c]

Your program outputs:
[c]
Field #1:
**
**

Field #2:
3
[/c]

But the output should be:
[c]
Field #1:
**
**

Field #2:
0
[/c]

Now you should realize where the mistake is......... for the second input you also cosider the * outside the board that was in the first input.

I added
[c]
for(i=0;i<101;i++)
for(j=0;j<101;j++)
c[j] = '.';
[/c]

after scanf.......... and got AC.

Hope it helps.
:wink:
midra
Experienced poster
Posts: 119
Joined: Fri Feb 13, 2004 7:20 am
Contact:

Post by midra »

THANKS A LOT!!!!!
I really appreciate your answer. I got AC!!!! :D

...I got surprised when I saw your statistics! You got a lot of problems solved!!Congratulations for it!

Kind regards
:D
Last edited by midra on Fri Oct 26, 2012 7:05 am, edited 1 time in total.
ranjit
New poster
Posts: 34
Joined: Fri Jan 30, 2004 11:22 am
Location: india

10189 wa

Post by ranjit »

Code: Select all

#include<iostream>
#include<cstdio>
#include<cctype>

using namespace std;

char a[110][110];
int n,m;

void assign()
{
  for(int i=0;i<m;i++)
    {
      for(int j=0;j<n;j++)
	{
	  if(a[i][j] == '*')
	    {
	      if(i > 0 && j > 0 && isdigit(a[i-1][j-1]))
		a[i-1][j-1] ++;
	      if(i > 0 && isdigit(a[i-1][j]))
		a[i-1][j] ++;
	      if(j < n-1 && i > 0 && isdigit(a[i-1][j+1]))
		a[i-1][j+1] ++;
	      if(j > 0 && isdigit(a[i][j-1]))
		a[i][j-1] ++;
	      if(j < n-1 && isdigit(a[i][j+1]))
		a[i][j+1] ++;
	      if(i < n-1 && j > 0 && isdigit(a[i+1][j-1]))
		a[i+1][j-1] ++;
	      if(i < n-1 && isdigit(a[i+1][j]))
		a[i+1][j] ++;
	      if(i < n-1 && j < n-1 && isdigit(a[i+1][j+1]))
		a[i+1][j+1] ++;
	    }
	}
    }
}

int main()
{
  int c = 1;
  cin>>m>>n;
  while(m != 0 && n != 0)
    {
      for(int i=0;i<m;i++)
	{
	  for(int j=0;j<n;j++)
	    {	
	      cin>>a[i][j];
	      if(a[i][j] == '.')
		a[i][j] = '0';
	    }
	}
      assign();
      cout<<"Field #"<<c<<":\n";
      c ++;
      for(int i=0;i<m;i++)
	{
	  for(int j=0;j<n;j++)
	    cout<<a[i][j];
	  cout<<"\n";
	}
      cout<<"\n";
      cin>>m>>n;
    }
  return 0;
}
i dont know why i am getting wa.
is there any problem in taking input from file.

thanx in advance.
mattapayne
New poster
Posts: 8
Joined: Thu Jun 17, 2004 5:50 am

10189 - WA Can't Seem To Find What's Wrong ...

Post by mattapayne »

Would anyone like to have a quick look? I've exhausted all possibilities that I could think up.

[C++]
/*BEGIN CODE*/

#include <iostream>
#include <vector>
using namespace std;
//number of rows in the field array
const int ROW = 110;
//number of columns in the field array
const int COL = 110;
//increments every time a field struct is printed
int fieldCounter = 1;
//Field struct to hold data relating to individual fields
struct Field
{
int rows;
int columns;
char grid[ROW][COL];
};

int main()
{
//function to output individual Field
void printField(Field, bool);
//vector to hold each Field struct
vector<Field> arrayStore;
//variables representing the row and column of the current Field
int n, m;
//read in rows and columns
cin >> n >> m;
//if both n and m are 0, quit
if(n == 0 && m == 0)
exit(1);
//while rows and columns are not both 0
while(n != 0 || m != 0)
{
//if either n or m is 0, quit
if(n == 0 || m == 0)
exit(1);

Field f;

f.rows = n;
f.columns = m;

//loop through and add each char to array
for(int i=0; i<n; ++i)
{
for(int j=0; j<m; ++j)
{
cin >> f.grid[j];
}
}

//add Field struct to vector
arrayStore.push_back(f);
//get next row and column
cin >> n >> m;
} //end while

//loop through the vector of Field structs
for(unsigned int i=0; i<=arrayStore.size()-1; i++)
{
if(i != arrayStore.size() -1)
printField(arrayStore, false);
else
printField(arrayStore, true);
}
}
//Print an individual Field struct according to Minesweeper rules
void printField(Field f, bool lastField)
{
//variable representing the number of mines
int bombs;
cout << "\nField #" << fieldCounter++ << ":\n";

for(int a=0; a<f.rows; a++)
{
for(int b=0; b<f.columns; b++)
{
if(f.grid[a] == '*')
{
cout << '*';
continue;
}
bombs = 0;

if(a>0 && f.grid[a-1] == '*')
bombs++;
if(a>0 && f.grid[a-1][b-1] == '*')
bombs++;
if(a>0 && b<(f.columns-1) && f.grid[a-1][b+1] == '*')
bombs++;

if(a<(f.rows-1) && f.grid[a+1] == '*')
bombs++;
if(b>0 && a<(f.rows-1) && f.grid[a+1][b-1] == '*')
bombs++;
if(b>0 && f.grid[a][b-1] == '*')
bombs++;
if(b<(f.columns-1) && f.grid[a][b+1] == '*')
bombs++;
if(a<(f.rows-1) && b<(f.columns-1) && f.grid[a+1][b+1] == '*')
bombs++;
cout << bombs;
}
if(lastField)
{
if(a != f.rows -1)
cout << "\n";
}
else
cout << "\n";
}
}

/*END CODE*/

Thanks in advance for any direction.

Matt
Post Reply

Return to “Volume 101 (10100-10199)”