292
技術社區[雲棲]
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;
}
最後更新:2017-04-03 05:38:55