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;
}

总结

水题,不解释

目录
相关文章
|
机器学习/深度学习 人工智能 算法
迷宫老鼠问题(Maze Mouse Problem
迷宫老鼠问题(Maze Mouse Problem)是一个经典的计算机算法问题,用于测试算法在解决寻路问题方面的性能。这个问题可以应用于人工智能、机器学习和导航算法等领域。
93 6
|
Python
python实现简单的snake game!
python实现简单的snake game!
103 0
|
人工智能
jump game
最后一步:如果青蛙能跳到最后一块石头n-1,我们考虑他跳的最后一步,这一步是从石头i跳过来,i&lt;n-1 这需要两个条件同时满足: 1.青蛙可以调到石头i; 2.最后一步不超过跳跃的最大距离:n-1-i &lt;= ai
114 0
jump game
《The Moon and Sixpence》Day 46
作者在旅途中反复琢磨Charles这样做的冬季和对世俗观点毫不在乎的态度。最后,作者回到伦敦去给Mrs.Strickland汇报在巴黎的情况。作者告诉Mrs.Strickland他在巴黎见到了Charled并且他的离开是因为他想画画,Mrs.Strickkland大吃一惊,丝毫不信。 3.好词佳句
103 0
《The Moon and Sixpence》Day 45
relentless adj 顽强的,持续的,坚定地,冷酷的 cuckoo n杜鹃鸟,布谷鸟 v杜鹃叫,不断重复
96 0
《The Moon and Sixpence》Day 44
作者和Charles来到一家咖啡厅,作者尝试用情感道义去规劝感化他,也朝他大加嘲讽试图骂醒他但都无济于事。最后,Charles告诉作者他来巴黎的原因是因为他想画画,想成为一个画家。
90 0
《The Moon and Sixpence》Day 42
errand n 差事,差使,使命 anguish n 痛苦 v感到极其痛苦 bliss n福佑 v欣喜若狂
83 0
|
存储 算法 测试技术