zoukankan      html  css  js  c++  java
  • hdu 4706 Children's Day(模拟)

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

    【题目大意】:

      用a-z排出N的形状,输出大小为3-10的N,如果超过z之后,重新从a开始

    下面是大小为3的N(其实这里的N是反的,呵呵)

    a e
    bdf
    c g

    大小为4的N
    h  n
    i mo
    jl p
    k  q

    【code】:

     1 #include <iostream>
     2 #include <stdio.h>
     3 #include <string.h>
     4 
     5 using namespace std;
     6 
     7 char str[11][11][11];
     8 int cnt;
     9 
    10 void solve(int id)
    11 {
    12     int n=id,i;
    13     for(i=0;i<n;i++)
    14     {
    15         str[id][i][0]=cnt%26+'a';
    16         cnt++;
    17     }
    18     for(i=n-2;i>0;i--)
    19     {
    20         str[id][i][n-i-1]=cnt%26+'a';
    21         cnt++;
    22     }
    23     for(i=0;i<n;i++)
    24     {
    25         str[id][i][n-1]=cnt%26+'a';
    26         cnt++;
    27     }
    28 }
    29 
    30 void print()
    31 {
    32     int i,j,k;
    33     for(i=3;i<=10;i++)
    34     {
    35         for(j=0;j<i;j++)
    36         {
    37             for(k=0;k<i;k++)
    38             {
    39                 if(str[i][j][k]>='a'&&str[i][j][k]<='z')    putchar(str[i][j][k]);
    40                 else putchar(' ');
    41             }
    42             putchar(10);
    43         }
    44     }
    45 }
    46 
    47 int main()
    48 {
    49     int i,j,k;
    50     cnt=0;
    51     memset(str,0,sizeof(str));
    52     for(i=3;i<=10;i++)
    53     {
    54         solve(i);
    55     }
    56     print();
    57     return 0;
    58 }
  • 相关阅读:
    Spring总结
    Json
    智能搜索
    Ajax
    include指令和include标签的区别
    jsp状态管理
    Model1
    JavaBean
    JSP内置对象的解析
    镜像地址管理工具nrm
  • 原文地址:https://www.cnblogs.com/crazyapple/p/3310901.html
Copyright © 2011-2022 走看看