HDU4706-Children's Day

简介:

Children's Day
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 781    Accepted Submission(s): 501


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 mo
jl 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
2013 ACM/ICPC Asia Regional Online —— Warmup
 


//没啥说的,二位数组画图...找规律
AC代码:

#include<stdio.h>
#include<String.h>
#include<ctype.h>
char a[15][15];
char English[27]="abcdefghijklmnopqrstuvwxyz";
int main()
{
 int i,j,n,m,p;
 n=3;m=1;p=0;
 while(n<=10&&m<=8)
    {
  memset(a,0,sizeof(a));
  for(i=0;i<n;i++)//左边的按0,0开始从上到下排
  {
   a[i][0]=English[p++];
   if(p>25)//到z之后让其从a开始
    p=0;
  }
  int x=n-2,y=1,r=m;
  while(r--)//中间的按从左下方到右下方排
  {
   a[x--][y++]=English[p++];
   if(p>25)
    p=0;
  }
  for(i=0;i<n;i++)//右边的按0,n-1从上到下排
  {
   a[i][n-1]=English[p++];
   if(p>25)
    p=0;
  }
  for(i=0;i<n;i++)
  { 
   for(j=0;j<n;j++)
   {
                if(isalpha(a[i][j]))//输出有字母的,没有的就设为空格
     printf("%c",a[i][j]);
    else
     printf(" ");
   }
   puts("");
  }
  n++;m++;//扩大“N”
 }
 return 0;
}
相关文章
|
9月前
hdoj 1028/poj 2704 Pascal's Travels(记忆化搜索||dp)
有个小球,只能向右边或下边滚动,而且它下一步滚动的步数是它在当前点上的数字,如果是0表示进入一个死胡同。求它从左上角到右下角到路径数目。 注意, 题目给了提示了,要用64位的整数。
30 0
HDU-1598,find the most comfortable road(并查集+枚举)
HDU-1598,find the most comfortable road(并查集+枚举)
|
Java
HDOJ/HDU 2087 剪花布条(indexOf()应用~~)
HDOJ/HDU 2087 剪花布条(indexOf()应用~~)
108 0
HDOJ/HDU 1062 Text Reverse(字符串翻转~)
HDOJ/HDU 1062 Text Reverse(字符串翻转~)
105 0
|
Web App开发 Java 数据安全/隐私保护
HDOJ(HDU) 1563 Find your present!(异或)
HDOJ(HDU) 1563 Find your present!(异或)
223 0
|
人工智能 Java
|
算法 编译器
LeetCode:658. Find K Closest Elements程序分析
好久没有练习算法了,以此纪研究生以来第一次练习算法题。 原题链接:https://leetcode.com/problems/find-k-closest-elements/description/ 题目描述:大概意思是给定一个数组[1,2,3,4,5]和两个常数k,x然后在数组中找到与x最近的的k个元素,找到后的元素依旧按照升序排列。
1708 0