OUVa 232 Crossword answer
来源:互联网 发布:大数据意义包括哪些 编辑:程序博客网 时间:2024/05/22 02:05
求一个网格中的横纵字符串
</pre><pre name="code" class="cpp">
#include "stdafx.h"#include<iostream>#include<string>#include<iomanip>using namespace std;typedef struct {char cval;int num;} Elem;int main(){#ifndef TESTFILE *fp;freopen_s(&fp, "data.in.txt", "r", stdin);freopen_s(&fp, "data.out.txt", "w", stdout);#endifint cnt = 0;int row = 0, col = 0;/*initialize the struct array*/const int conRow = 100;const int conCol = 100; Elem **eArr = new Elem*[conRow];for (int i = 0; i < conRow; ++i)eArr[i] = new Elem[conCol];while (cin >> row && row != 0) {cin >> col;string line;int index = 0;for (int i = 0; i < row; ++i) {cin >> line;for (int j = 0; j < col; ++j) {eArr[i][j].cval = line[j];if (line[j] != '*')if (i == 0 || j == 0 || eArr[i - 1][j].cval == '*' || eArr[i][j - 1].cval == '*')eArr[i][j].num = ++index;}}//endfor/*output across*/cnt++;if (cnt > 1)cout << endl;cout << "puzzle #" << cnt << ":" << endl;cout << "Across" << endl;for (int i = 0; i < row; ++i) {for (int j = 0;;) {while (j < col && eArr[i][j].cval == '*') j++;if (j < col)//first elemcout << setw(3) << eArr[i][j].num << ".";elsebreak;while (j < col && eArr[i][j].cval != '*')cout << eArr[i][j++].cval;cout << endl;}//endfor}//endforcout << "Down" << endl;int *pos = new int[col]();for (int j = 0; j < col; ++j) while (pos[j] < row && eArr[pos[j]][j].cval == '*') pos[j]++;while (true) {int i = 0;for (int j = 1; j < col; ++j)// lest oneif (pos[j] < pos[i])i = j;if (pos[i] == row)break;cout << setw(3) << eArr[pos[i]][i].num << ".";while (pos[i] < row && eArr[pos[i]][i].cval != '*')cout << eArr[pos[i]++][i].cval;cout << endl;while (pos[i] < row && eArr[pos[i]][i].cval == '*') pos[i]++;}//endwhile}return 0;}
0 0
- OUVa 232 Crossword answer
- uvaoj-232:crossword answer
- Crossword Answer UVa232
- UVA232 Crossword Answer
- UVa 232 Crossword Answer(纵横字谜的答案)
- 纵横字谜的答案(Crossword Answer,ACM/ICPC WOrld Finals 1994, UVa 232)
- uva 232 - Crossword Answers
- uva 232 - Crossword Answers
- UVa 232 - Crossword Answers
- UVa 232 - Crossword Answers
- UVa-232 - Crossword Answers
- Uva-232 - Crossword Answers
- uva---232--- Crossword Answers
- UVa 232 Crossword Answers
- 232 - Crossword Answers
- UVa 232 - Crossword Answers
- 232 - Crossword Answers
- UVa-232Crossword Answers
- 3019
- 检查Linux服务器性能
- ajaxFileUpload带参数提交
- json数据和bean之间的转换
- Android studio中某些快捷键
- OUVa 232 Crossword answer
- Bootstrap使用Javascript显示模态框后页面上移
- Hexo+Github Pages如何搭建并异地管理Blog
- 防火墙iptable的原理
- c++指针初识
- Java 8新的时间日期库
- [ASP.NET MVC]Entity Framework框架之CodeFirst数据迁移
- 开发板上syslog使用方法小结
- angular-模块-启动