Fox And Snake

简介: Fox And Snake

文章目录

一、Fox And Snake

总结


一、Fox And Snake

本题链接:


题目:

A. Fox And Snake

time limit per test2 seconds

memory limit per test256 megabytes

inputstandard input

outputstandard output

Fox Ciel starts to learn programming. The first task is drawing a fox! However, that turns out to be too hard for a beginner, so she decides to draw a snake instead.


A snake is a pattern on a n by m table. Denote c-th cell of r-th row as (r, c). The tail of the snake is located at (1, 1), then it’s body extends to (1, m), then goes down 2 rows to (3, m), then goes left to (3, 1) and so on.


Your task is to draw this snake for Fox Ciel: the empty cells should be represented as dot characters (’.’) and the snake cells should be filled with number signs (’#’).


Consider sample tests in order to understand the snake pattern.


Input

The only line contains two integers: n and m (3 ≤ n, m ≤ 50).


n is an odd number.


Output

Output n lines. Each line should contain a string consisting of m characters. Do not output spaces.


Examples

input

3 3

output

###

..#

###

input

3 4

output

####

...#

####

input

5 3

output

###

..#

###

#..

###


input

9 9

output

#########

........#

#########

#........

#########

........#

#########

#........

#########

本博客给出本题截图

image.png

image.png

题意:按照如图所示的样子打印出来结即可

AC代码

#include <iostream>
#include <algorithm>
using namespace std;
const int N = 55;
char g[N][N];
int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i ++ )
        for (int j = 1; j <= m; j ++ )
        {
            if (i % 2) g[i][j] = '#';
            else
            {
                if (j == 1 && !(i % 4))
                {
                    g[i][j]=  '#';
                    continue;
                }
                else if (j == m && !(i % 2) && g[i][1] != '#')
                {
                    g[i][j]=  '#';
                    continue;
                }
                g[i][j] = '.';
            }
        }
    for (int i = 1; i <= n; i ++ )
    {
        for (int j = 1; j <= m; j ++ )
            cout << g[i][j];
        puts("");
    }
    return 0;
}

总结

水题,不解释

目录
相关文章
|
7月前
190Echarts - 自定义系列(Girths of Black Cherry Trees)
190Echarts - 自定义系列(Girths of Black Cherry Trees)
13 0
|
7月前
252Echarts - 3D 曲面(Golden Rose)
252Echarts - 3D 曲面(Golden Rose)
37 0
|
12月前
|
Python
python实现简单的snake game!
python实现简单的snake game!
82 0
|
XML 测试技术 数据格式
Nose-3-精通
Nose-3-精通
143 0
Funny Car Racing - 最短路小技巧
题意: n个路口,m条街道,每条街道都是有向的 并且这m条街道open a秒 close b秒(循环往复),自己的车通过这条道路需要t秒 可以从路口等待某一条道路open,必须在道路close 之前通过,且必须在另一条道路open的时候进入 问能否从s点到达t点,如果不能,输出-1,如果能输出最短的时间 细节的地方加在了代码里,在建图的过程中,如果说a > t,那么说这条路无论如何是走不过去的,所以干脆直接不建边
71 0
《The Moon and Sixpence》Day 45
relentless adj 顽强的,持续的,坚定地,冷酷的 cuckoo n杜鹃鸟,布谷鸟 v杜鹃叫,不断重复
74 0
《The Moon and Sixpence》Day 44
作者和Charles来到一家咖啡厅,作者尝试用情感道义去规劝感化他,也朝他大加嘲讽试图骂醒他但都无济于事。最后,Charles告诉作者他来巴黎的原因是因为他想画画,想成为一个画家。
76 0
《The Moon and Sixpence》Day 46
作者在旅途中反复琢磨Charles这样做的冬季和对世俗观点毫不在乎的态度。最后,作者回到伦敦去给Mrs.Strickland汇报在巴黎的情况。作者告诉Mrs.Strickland他在巴黎见到了Charled并且他的离开是因为他想画画,Mrs.Strickkland大吃一惊,丝毫不信。 3.好词佳句
83 0
《The Moon and Sixpence》Day 42
errand n 差事,差使,使命 anguish n 痛苦 v感到极其痛苦 bliss n福佑 v欣喜若狂
65 0