uva 10189 Minesweeper

/*
   	Minesweeper
   	WA了n次才知道uva格式错了也返回wa没有pe啊尼玛
*/
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
char a[105][105];
int main()
{
    int i,j,n,m,x=0;
   //freopen("./pcio/110102.inp","r",stdin);
    while(scanf("%d%d",&n,&m),m+n)
    {
        memset(a,'.',105*105);
        getchar();
        for(i=1; i<=n; i++)
        {
            for(j=1; j<=m; j++)
                scanf("%c",&a[i][j]);
            getchar();
        }
        for(i=1; i<=n; i++)
            for(j=1; j<=m; j++)
            {
                int num=0;
                if(a[i][j]=='.')
                {
                    if(a[i+1][j]=='*')
                        num++;
                    if(a[i-1][j]=='*')
                        num++;
                    if(a[i][j+1]=='*')
                        num++;
                    if(a[i][j-1]=='*')
                        num++;
                    if(a[i+1][j+1]=='*')
                        num++;
                    if(a[i-1][j-1]=='*')
                        num++;
                    if(a[i-1][j+1]=='*')
                        num++;
                    if(a[i+1][j-1]=='*')
                        num++;
                    a[i][j]=num+'0';
                }
            }
        if(x>0)
            puts("");
        printf("Field #%d:\n",++x);
        for(i=1; i<=n; i++)
        {
            for(j=1; j<=m; j++)
                printf("%c",a[i][j]);
            puts("");
        }
    }
    return 0;
}
时间: 2024-07-29 05:54:09

uva 10189 Minesweeper的相关文章

UVa 10189 Minesweeper (模拟)

10189 - Minesweeper Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1130 The Problem Have you ever played Minesweeper? It's a cute little game which comes

UVa 10602

链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1543 类型:贪心 原题: Company Macrohard has released it's new version of editor Nottoobad, which can understand a few voice commands.

UVa 10392 Factoring Large Numbers:素因子分解

10392 - Factoring Large Numbers Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=100&page=show_problem&problem=1333 One of the central ideas behind much cryptography is that factoring

UVa 10182 Bee Maja:规律&amp;amp;O(1)算法

10182 - Bee Maja Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1123 Maja is a bee. She lives in a bee hive with thousands of other bees. This bee hive c

算法题之UVA 763

Fibinary Numbers The standard interpretation of the binary number 1010 is 8 + 2 = 10. An alternate way to view the sequence ``1010'' is to use Fibonacci numbers as bases instead of powers of two. For this problem, the terms of the Fibonacci sequence

算法题:UVa 11461 Square Numbers (简单数学)

11461 - Square Numbers Time limit: 1.000 seconds http://uva.onlinejudge.org/index.php? option=com_onlinejudge&Itemid=8&category=467&page=show_problem&problem=24 56 A square number is an integer number whose square root is also an integer.

UVa 10183 How Many Fibs? (统计斐波那契数个数&amp;amp;高精度)

10183 - How Many Fibs? Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=115&page=show_problem&problem=1124 Recall the definition of the Fibonacci numbers:    f1 := 1    f2 := 2    fn :

UVa 701 The Archeologists&#039; Dilemma: 数学及枚举

701 - The Archeologists' Dilemma Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=115&page=show_problem&problem=642 An archeologist seeking proof of the presence of extraterrestrials i

UVa 550 Multiplying by Rotation:模拟乘法

550 - Multiplying by Rotation Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=100&page=show_problem&problem=491 Warning: Not all numbers in this problem are decimal numbers! Multiplic