CodeForces 510A Fox And Snake
2016-08-14 15:45
393 查看
A. Fox And Snake
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard 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
output
input
output
input
output
input
output
水题,打印图形
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard 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
######### ........# ######### #........ ######### ........# ######### #........ #########
水题,打印图形
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int main() { int n,m,i,j; while(scanf("%d%d",&n,&m)!=EOF) { for(i=1;i<=n;i++) { if(i%2) { for(j=1;j<=m;j++) printf("#"); printf("\n"); } else if(i%4==0) { printf("#"); for(j=2;j<=m;j++) printf("."); printf("\n"); } else { for(j=1;j<m;j++) printf("."); printf("#\n"); } } } return 0; }
相关文章推荐
- Android PLT/GOT 符号重定向过程
- PHPCMS取消文章页自动截取摘要
- HTML相关知识
- CodeUp-1036 Problem B 镂空三角形
- SVN服务器的搭建和使用
- 做个简单的RSS订阅(ASP.NET Core),节省自己的时间
- 王爽《汇编语言》实验15——安装新的INT 9中断例程
- iOS开发系列--Objective-C之类和对象
- Integer与int的种种比较
- jquery知识
- 设计模式GOF23——状态模式
- 145. Binary Tree Postorder Traversal
- 小鱼儿与花无雀
- 设计模式之单例模式
- objective c 中的继承和多态简单示意(二)
- Linux下进度条小程序
- .NET微信公众号开发-6.0模板消息
- PowerDesigner 15.1 安装步骤详细图解及破解
- 防止Class类反编译的方法,对Class进行加密
- java的面向对象编程一