C.纸上文字
https://codeforces.com/contest/1850/problem/C
C.纸上文字
每次测试的时间限制:1 秒
每次测试的内存限制:256 兆字节
输入:标准输入
输出:标准输出
在一个由点组成的 8×8网格上,一列从上到下垂直书写着一个由小写拉丁字母组成的单词。这是什么?
输入
输入由多个测试用例组成。输入的第一行包含一个整数 t ( 1≤t≤1000 ) - 测试用例的数量。
每个测试用例由 8 行组成,每行包含 8 个字符。网格中的每个字符要么是 .. (代表一个点),要么是一个小写拉丁字母( a - z )。
单词完全位于一列中,从开头到结尾是连续的(没有间隙)。请参阅输入示例,以便更好地理解。
**输出**
对于每个测试用例,输出一行包含由小写拉丁字母( a - z )组成的单词,该单词从上到下竖写一列。
输入
5
........
........
........
........
...i....
........
........
........
........
.l......
.o......
.s......
.t......
........
........
........
........
........
........
........
......t.
......h.
......e.
........
........
........
........
........
.......g
.......a
.......m
.......e
a.......
a.......
a.......
a.......
a.......
a.......
a.......
a.......
输出:
i
lost
the
game
aaaaaaaa
思路:
模拟
代码:
#include <bits/stdc++.h>
using namespace std;
int main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int T;cin >> T;while(T--){bool found = true;int startx,starty;char a[10][10] = {0};for(int i = 1 ; i <= 8 ; i++){for(int j = 1 ; j <= 8 ; j++){cin >> a[i][j];}}for(int i = 1 ; i <= 8 && found; i++){for(int j = 1 ; j <= 8 && found; j++){if(a[i][j] >= 'a' && a[i][j] <= 'z'){startx = i;starty = j;found = false;}}}while(startx <= 8 && starty <= 8 && a[startx][starty] != '.'){cout << a[startx][starty];startx++;}cout << '\n';}return 0;
}