B. Present from Lena
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Vasya's birthday is approaching and Lena decided to sew a patterned handkerchief to him as a present. Lena chose digits from 0 to n as the pattern. The digits will form a rhombus. The largest digit n should be located in the centre. The digits should decrease as they approach the edges. For example, for n = 5 the handkerchief pattern should look like that:

          0
        0 1 0
      0 1 2 1 0
    0 1 2 3 2 1 0
  0 1 2 3 4 3 2 1 0
0 1 2 3 4 5 4 3 2 1 0
  0 1 2 3 4 3 2 1 0
    0 1 2 3 2 1 0
      0 1 2 1 0
        0 1 0
          0

Your task is to determine the way the handkerchief will look like by the given n.

Input

The first line contains the single integer n (2 ≤ n ≤ 9).

Output

Print a picture for the given n. You should strictly observe the number of spaces before the first digit on each line. Every two adjacent digits in the same line should be separated by exactly one space. There should be no spaces after the last digit at the end of each line.

Sample test(s)
Input
2
Output
    0
0 1 0
0 1 2 1 0
0 1 0
0
Input
3
Output
      0
0 1 0
0 1 2 1 0
0 1 2 3 2 1 0
0 1 2 1 0
0 1 0
0
 #include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int n;
cin>>n;
for(int i = ; i < n + ; i ++)
{
for(int j = ; j < i * + ; j ++)
{
for(int k = i* ; j== && k < n * ; k++ )cout<<" ";
if(j<=i&&j!=i*)cout<<j<<" ";
else if(j<=i)cout<<j;
else if(j!=i*)cout<<i*-j<<" ";
else cout<<i*-j;
}
cout<<endl;
}
for(int i = ; i < n ; i++)
{
for(int j = ; j < (n - i )* - ; j++)
{
for(int k = ; j==&& k < (i+)* ; k++)cout<<" ";
if(j<=n-i- && j!= (n-i)*-)cout<<j<<" ";
else if(j<=n-i-)cout<<j;
else if(j!=(n-i)*-)cout<<(n-i -)* -j <<" ";
else cout<<(n-i-)*-j;
}
cout<<endl; }
}

cf 118B的更多相关文章

  1. ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'

    凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...

  2. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  3. cf Round 613

    A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...

  4. ARC下OC对象和CF对象之间的桥接(bridge)

    在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...

  5. [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现

    1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...

  6. CF memsql Start[c]UP 2.0 A

    CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...

  7. CF memsql Start[c]UP 2.0 B

    CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...

  8. CF #376 (Div. 2) C. dfs

    1.CF #376 (Div. 2)    C. Socks       dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...

  9. CF #375 (Div. 2) D. bfs

    1.CF #375 (Div. 2)  D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...

随机推荐

  1. Java与C#不同

    1.C#方法定义可以有默认参数,而Java则不支持该方式. C#方法定义 public void ShowMessage(string text,string orderId="" ...

  2. js函数的定义和调用

    函数的定义 函数使用function 声明,后跟一组参数以及函数体,语法如下: function functionName([age0,age1,......argn]){ statements } ...

  3. Java合并数组的实现方式

    String[] aa = {"11","22","33"};String[] bb = {"44","55& ...

  4. java中重写

    1.重写[针对父类与子类而言]---------即java的多态性[子类与父类间有相同的名称和参数,此方法就被重写Overriding:又称:方法覆盖] 子类对父类的允许访问的方法的实现过程进行重新编 ...

  5. MySQL总结(3)

    ORDER BY 与 GROUP BY ORDER BY GROUP BY 排序产生的输出 分组行.但输出可能不是分组的顺序 不一定需要 如果与聚集函数一起使用列(或表达式)则必须使用 任意列都可以使 ...

  6. 探索ASP.Net Core 3.0系列二:聊聊ASP.Net Core 3.0 中的Startup.cs

    原文:探索ASP.Net Core 3.0系列二:聊聊ASP.Net Core 3.0 中的Startup.cs 前言:.NET Core 3.0 SDK包含比以前版本更多的现成模板. 在本文中,我将 ...

  7. 理解 OutOfMemoryError 异常

    OutOfMemoryError 异常应该可以算得上是一个非常棘手的问题.JAVA 的程序员不用像苦逼的 C 语言程序员手动地管理内存,JVM 帮助他们分配内存,释放内存.但是当遇到内存相关的问题,就 ...

  8. HTML文本格式化标签(Formatting)

    <b>粗体文本</b> <code>计算机代码</code> <em>强调文本</em> <i>斜体文本</i ...

  9. [七月挑选]windows上面的发音

    title: windows上面的发音 开始 love.vbs: CreateObject("SAPI.SpVoice").Speak "I love YOU" ...

  10. IOS绘图详解(http://blog.163.com/wkyuyang_001/blog/static/10802122820133190545227/)

    14.1 Quartz概述 Quartz是Mac OS X的Darwin核心之上的绘图层,有时候也认为是CoreGraphics.共有两种部分组成Quartz: Quartz Compositor,合 ...