【习题 3-6 UVA - 232】Crossword Answers
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
模拟题。注意场宽为3
【代码】
#include <bits/stdc++.h>
using namespace std;
const int N = 10;
int n, m, num[N + 10][N + 10], last[N + 10];
string s[N + 10];
int main()
{
/*freopen("F:\\rush.txt", "r", stdin);*/
int kk = 0;
while (cin >> n && n)
{
if (kk) puts("");
memset(last, 0, sizeof last);
cin >> m;
for (int i = 0; i < n; i++) cin >> s[i];
int cnt = 0;
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++)
if (s[i][j]!='*' && (j == 0 || i == 0 || s[i][j - 1] == '*' || s[i - 1][j] == '*'))
num[i][j] = ++cnt;
printf("puzzle #%d:\n", ++kk);
printf("Across\n");
for (int i = 0; i < n; i++)
{
int now = 0;
for (int j = now; j < m; j++)
if (j >= now && isalpha(s[i][j]) && (j == 0 || s[i][j - 1] == '*'))
{
printf("%3d.", num[i][j]);
while (j < m && isalpha(s[i][j]))
putchar(s[i][j++]);
puts("");
now = j;
}
}
printf("Down\n");
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
if (isalpha(s[i][j]) && (i == 0 || s[i - 1][j] == '*') && i >= last[j])
{
printf("%3d.", num[i][j]);
int now = i;
while (now < n && s[now][j] != '*') putchar(s[now++][j]);
last[j] = now;
puts("");
}
}
}
return 0;
}
【习题 3-6 UVA - 232】Crossword Answers的更多相关文章
- UVa 232 Crossword Answers
Crossword Answers A crossword puzzle consists of a rectangular grid of black and white squares and ...
- UVa232.Crossword Answers
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- Uva 232 一个换行WA 了四次
由于UVA OJ上没有Wrong anwser,搞的多花了好长时间去测试程序,之前一直以为改OJ有WA,后来网上一搜才知道没有WA,哎哎浪费了好长时间.此博客用来记录自己的粗心大意. 链接地址:htt ...
- poj 1888 Crossword Answers 模拟题
Crossword Answers Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 869 Accepted: 405 D ...
- Crossword Answers UVA - 232
题目大意 感觉挺水的一道题.找出左面右面不存在或者是黑色的格子的白各,然后编号输出一横向单词和竖向单词(具体看原题) 解析 ①找出各个格子的编号 ②对每个节点搜索一下 ③输出的时候注意最后一个数据后面 ...
- 紫书第三章训练1 D - Crossword Answers
A crossword puzzle consists of a rectangular grid of black and white squares and two lists of defini ...
- UVA 232 Corssword Answer
题意:输入m*n大小的字符串(里面有*,*为黑格,其他为白格),然后对它编号,编号规则为从左到右,从上往下,且左边或上面没有白格(可能是黑格或越界),如下图: 注意: ①除第一次输出答案外,其余每次输 ...
- Crossword Answers -------行与列按序输出
题目链接:https://vjudge.net/problem/UVA-232#author=0 题意:关键句:The de nitions correspond to the rectangular ...
- ACM训练计划建议(写给本校acmer,欢迎围观和指正)
ACM训练计划建议 From:freecode# Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...
随机推荐
- android-从官网下拉源码(ubuntu)
今天终于成功的从谷歌官网上下载了android 源码.中间折腾了好久,最终总算有所收获 1.下载repo curl https://storage.googleapis.com/git-repo-do ...
- PatentTips - Enhancing the usability of virtual machines
BACKGROUND Virtualization technology enables a single host computer running a virtual machine monito ...
- Ueditor 七牛集成
UEDITOR修改成功的 http://blog.csdn.net/uikoo9/article/details/41844747 http://blog.csdn.net/u010717403/ar ...
- mvc定时执行任务(获取气象台的气象数据,定时新增)
1.定时任务: gloabl.asax文件Application_Start()方法注册: System.Timers.Timer t = new System.Timers.Timer(theInt ...
- emacs 为什么找不到运行程序?
我记得前段时间有个朋友问我为什么在emacs中打不开matlab程序?明明在terminal下是能打开的,却在emacs中不行. 今天自己最终遇到了相似的问题,我今天安装racket 6.0.安装好后 ...
- 63.当当网txt数据按行切割与合并
获取文件有多少行 //获取文件有多少行 int getN(char *path) { FILE *pf = fopen(path, "r"); if (pf==NULL) { ; ...
- Windows/Linux下磁盘使用的图形化工具简介
Windows/Linux下磁盘使用的图形化工具简介 如何以图形界面查看磁盘及分区的大小及剩余容量呢?今天我为大家介绍两款Windows/Linux下磁盘使用的图形化工具分别是Spacesniff ...
- call、apply、bind 区别
1.为什么要用 call .apply? 为了 改变方法里面的属性而不去改变原来的方法 function fruits() {} fruits.prototype = { color: "r ...
- 洛谷 P2677 超级书架 2
P2677 超级书架 2 题目描述 Farmer John最近为奶牛们的图书馆添置了一个巨大的书架,尽管它是如此的大,但它还是几乎瞬间就被各种各样的书塞满了.现在,只有书架的顶上还留有一点空间. 所有 ...
- ArcEngine的ToolbarControl解析
转自Love Lyre原文 ArcEngine的ToolbarControl解析 ToolbarControlClass有三个主要的接口: IToolbarControl, IToolbarContr ...