zoukankan      html  css  js  c++  java
  • 模拟与高精度 P2670 扫雷游戏

    题目

    https://www.luogu.com.cn/problem/P2670

    代码

    #include<iostream>
    #include<cstdio>
    #include<string>
    #include<cstring>
    using namespace std;
    int answer[200][200];
    #define inf 500
    int main()
    {
        int n, m;
        string tmp;
        scanf("%d%d", &n, &m);
        for (int i = 0; i < n; i++)
        {
            cin >> tmp;
            for (int j = 0; j < m; j++)
            {
                if (tmp[j] == '*')
                {
                    if (i - 1 >= 0 && j - 1 >= 0)answer[i - 1][j - 1]++;
                    if (i - 1 >= 0)answer[i - 1][j]++;
                    if ( j - 1 >= 0)answer[i][j - 1]++;
                    answer[i][j] = -inf;
                    if (i +1 <n && j -1>=0)answer[i + 1][j-1]++;
                    if (i + 1 <n )answer[i + 1][j]++;
                    if (i - 1 >= 0 && j + 1<m)answer[i - 1][j + 1]++;
                    if ( j + 1 <m)answer[i][j + 1]++;
                    if (i + 1 <n && j +1<m)answer[i + 1][j + 1]++;
                }
            }
        }
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < m; j++)
            {
                if (answer[i][j] < 0)
                    printf("*");
                else
                    printf("%d", answer[i][j]);
            }
            printf("
    ");
        }
    
    
    }
  • 相关阅读:
    SPI简述
    stm32和sd卡
    BKP和RTC
    Lwip与底层的接口
    关于Ad-hoc
    stm32 引脚映射 和 ADC
    GDB使用总结
    linux管道和重定向
    学习python的第四天
    学习pyton的第三天
  • 原文地址:https://www.cnblogs.com/Jason66661010/p/12834512.html
Copyright © 2011-2022 走看看