U E D R , A S I H C RSS

Mine Sweeper/김상섭

~cpp
#include <iostream>
#include <vector>
using namespace std;

struct point
{
	int row;
	int col;
};

vector<point> test;
int col, row, i, j,temp_row, temp_col, map[101][101];
int director_row[8] = {-1,-1,-1,0,0,1,1,1};
int director_col[8] = {-1,0,1,-1,1,-1,0,1};
int count = 1;
char temp_char[101];
point temp_point;

void seb_process()
{
	

}

void process()
{
	for(i = 1; i <= row; i++)
	{
		for(j = 1; j <= col; j++)
			map[i][j] =0;
	}
	
	for(i = 0; i < test.size(); i++)
		map[test[i].row][test[i].col] = -1;

	for(i = 0; i < test.size(); i++)
	{
		for(j = 0; j < 8; j++)
		{
			temp_row = test[i].row + director_row[j];
			temp_col = test[i].col + director_col[j];
			if(temp_row > 0 && temp_row <= row && temp_col > 0 && temp_col <= col && map[temp_row][temp_col] != -1)
				map[temp_row][temp_col]++;
		}

	}


	if(count != 1)
		cout << endl;
	cout << "Field #" << count++ << ":\n";
	for( i = 1; i <= row; i++)
	{
		for(j = 1; j <= col; j++)
		{
			if(map[i][j] == -1)
				cout << "*";
			else
				cout<< map[i][j];
		}
		cout << endl;
	}
}

int main()
{
	cin >> row >> col;
	while(row != 0 || col !=0)
	{
		for(i = 1; i <= row; i++)
		{
			cin >> temp_char;
			for( j = 1; j <= col; j++)
			{
				if(temp_char[j-1] == '*')
				{
					temp_point.row = i;
					temp_point.col = j;
					test.push_back(temp_point);
				}
			}
		}
			
		process();
		test.clear();
		cin >> row >> col;
	}
	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:46
Processing time 0.0064 sec