POJ 2612
#include<iostream>
#include<stdio.h>
#include<algorithm>
#define MAXN 11
using namespace std; char _m[MAXN][MAXN];
char mark[MAXN][MAXN];
int dig[MAXN][MAXN]; int main()
{
//freopen("acm.acm","r",stdin);
int num;
int i;
int j;
int tem;
bool boo;
cin>>num;
boo = false;
for(i = ; i < num; ++ i)
{
for(j = ; j < num; ++ j)
{
cin>>_m[i][j];
}
}
for(i = ; i < num; ++ i)
{
for(j = ; j < num; ++ j)
{
cin>>mark[i][j];
}
}
for(i = ; i < num; ++ i)
{
for(j = ; j < num; ++ j)
{
tem = ;
if(mark[i][j] == 'x')
{
if(i > )
{
if(_m[i-][j] == '*')
++ tem;
}
if(i < num-)
{
if(_m[i+][j] == '*')
++ tem;
}
if(j > )
{
if(_m[i][j-] =='*')
++ tem;
}
if(j < num-)
{
if(_m[i][j+] == '*')
++ tem;
}
if(i > && j > )
{
if(_m[i-][j-] == '*')
++ tem;
}
if(i > &&j < num-)
{
if(_m[i-][j+] == '*')
++ tem;
}
if(i < num-&&j > )
{
if(_m[i+][j-] == '*')
++ tem;
}
if(i < num-&&j < num-)
{
if(_m[i+][j+] == '*')
++ tem;
}
dig[i][j] = tem;
if(_m[i][j] == '*')
boo = true;
}
}
}
for(i = ; i < num; ++ i)
{
for(j = ; j < num; ++ j)
{
if(boo && _m[i][j] == '*')
cout<<_m[i][j];
else if(mark[i][j] == '.')
cout<<mark[i][j];
else
cout<<dig[i][j];
}
cout<<endl;
}
}
POJ 2612的更多相关文章
- poj 2612 Mine Sweeper
Mine Sweeper Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6429 Accepted: 2500 Desc ...
- HDU 2612 (BFS搜索+多终点)
题目链接: http://poj.org/problem?id=1947 题目大意:两人选择图中一个kfc约会.问两人到达时间之和的最小值. 解题思路: 对于一个KFC,两人的BFS目标必须一致. 于 ...
- poj 1265 Area 面积+多边形内点数
Area Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 5861 Accepted: 2612 Description ...
- poj和hdu部分基础算法分类及难度排序
最近想从头开始刷点基础些的题,正好有个网站有关于各大oj的题目分类(http://www.pythontip.com/acm/problemCategory),所以写了点脚本把hdu和poj的一些题目 ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
- POJ 2356. Find a multiple 抽屉原理 / 鸽巢原理
Find a multiple Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7192 Accepted: 3138 ...
- POJ 2965. The Pilots Brothers' refrigerator 枚举or爆搜or分治
The Pilots Brothers' refrigerator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 22286 ...
- POJ 1753. Flip Game 枚举or爆搜+位压缩,或者高斯消元法
Flip Game Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 37427 Accepted: 16288 Descr ...
- POJ 3254. Corn Fields 状态压缩DP (入门级)
Corn Fields Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9806 Accepted: 5185 Descr ...
随机推荐
- hashCode() 和equals() 区别和作用(转)
出处:https://www.jianshu.com/p/5a7f5f786b75 本章的内容主要解决下面几个问题: 1 equals() 的作用是什么? 2 equals() 与 == 的区别是什么 ...
- boost-数据类型之auto、any、tuple、variant
1.auto.decltype auto是C++11中的关键字,它可以通过类型推导自动得到变量或对象的类型,需要注意的是auto会忽略引用,因为引用其实就代表原对象: #include <v ...
- Transforming Real-Time Task Graphs to Improve Schedulability
Basic idea: insert artificial delays to the release times of certain vertices of a task graph to ge ...
- 哪些优秀的 Windows 小工具,类似 clover 或 everything
有哪些优秀的 Windows 小工具,类似 clover 或 everything? 目前已知的有everything, listary, total commander, clover, dexpo ...
- s5-11 距离矢量路由选择协议
距离矢量路由选择(Distance Vector:DV) 每个路由器维护一张表,表中列出了当前已知的到每个目标 的最佳距离,以及为了到达那个目标,应该从哪个接口转发. 距离矢量路由选择(Distanc ...
- HDU 4310 Hero (贪心)
题意:给定你有 n 个敌人,你的伤害是 1,给出每个敌人的伤害,和敌人的血量,每一回合你可以攻击一个敌人,并且所有敌人都会攻击你,除非它已经死了,问你最少要多少要消耗多少血量. 析:一个很明显的贪心问 ...
- poj 1328 Radar Installation(贪心+快排)
Description Assume the coasting is an infinite straight line. Land is in one side of coasting, sea i ...
- Cmd Markdown语法参考
https://www.zybuluo.com/mdeditor markdown语法说明 Markdown中公式的写法 $$P(X=k)=C_n^kp^k(1-p)^{n-k}$$ 欢迎使用 Cmd ...
- 20155326 2017-2018-1 《信息安全系统设计基础》第2周学习及课堂总结myod
20155326 2017-2018-1 <信息安全系统设计基础>第1次学习及课堂总结myod 虚拟机之前出了一些问题,然后我重新弄了一个新的虚拟机. 先在虚拟机里面安装了git. 安完以 ...
- Android 响应menu,back键,点击外部消失
点击外部消失,只需要设置popupWindow.setBackgroundDrawable(new PaintDrawable()); 设置 popupWindow.setFocusable(true ...