zoukankan      html  css  js  c++  java
  • hduoj 4706 Children's Day 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4706

    Children's Day

    Time Limit: 2000/1000 MS (Java/Others) 

       Memory Limit: 32768/32768 K (Java/Others)

    Problem Description
    Today is Children's Day. Some children ask you to output a big letter 'N'. 'N' is constituted by two vertical linesand one diagonal. Each pixel of this letter is a character orderly. No tail blank is allowed. For example, this is a big 'N' start with 'a' and it's size is 3.
    a e 
    bdf
    c g
    Your task is to write different 'N' from size 3 to size 10. The pixel character used is from 'a' to 'z' continuously and periodic('a' is reused after 'z').
     
    Input
    This problem has no input.
     
    Output
    Output different 'N' from size 3 to size 10. There is no blank line among output.
     
    Sample Output
    a e
    bdf
    c g
    h    n
    i  m o
    j l  p
    k    q
    .........
    r    j
    Hint
    Not all the resultsare listed in the sample. There are just some lines. The ellipsis expresseswhat you should write.
     
    Source

    分析:

    输出由字符组成的‘N’  , 三到十的大小。(模拟一下就可以啦)

    AC代码:

     1 #include<cstdio>
     2 #include<cstring>
     3 using namespace std;
     4 char map[15][15];
     5 int main() {
     6     int k = 0;
     7     for(int n = 3;n <= 10;n++) {
     8         
     9         //memset(map,'
    ',sizeof(map));
    10         for(int i = 0;i <= n;i++) {
    11             for(int j = 0;j < n;j++) {
    12                 if(i == 0 || i == n - 1 || i + j == n - 1) {
    13                     map[j][i] = k % 26 + 'a';
    14                     k++;
    15                 } else if(i == n) {
    16                     map[j][i] = '';
    17                 } else map[j][i] = ' ';
    18             }        
    19         }
    20         
    21         for(int i = 0;i < n;i++)
    22             printf("%s
    ",map[i]);
    23     }
    24     return 0;
    25 }
    View Code
  • 相关阅读:
    HDU 2010 水仙花数
    HDU 2009 求数列的和
    HDU 2008 数值统计
    Nginx实现反向代理
    vue-router 实现分析
    区分slice,splice和split方法
    notify()和notifyAll()主要区别
    移动端页面兼容性问题解决方案整理
    clearfix的用法
    前端js面试题
  • 原文地址:https://www.cnblogs.com/jeff-wgc/p/4466927.html
Copyright © 2011-2022 走看看