北邮oj 题

时间:2022-11-01 14:25:12

题目描述

Every year,prince prepares a birthday gift for princess.The gift is a box,which is decorated with jewel.
As princess grows older,the level of the jewelry box  gradually increase from A to Y.
Every level N jewelry box will be packed in level (N-1) jewelry box(except level 1 jewelry box).
For example,when princess was 1 year old,she got a level-A (level 1) jewelry box.When pricess was 2 years old,she got a level-B(level 2) jewelry box.The level-B(level 2)jewelry box was packed in level-A(level 1) jewelry box.
Because prince has obsessive-compulsive disorder, there will be a paper box between two jewelry box.
Please help prince to determine the birthday gift.

输入格式

The first line contains an integer T.(0<T<=20)
Then T test cases follow.
Each test case contains an interger N(1<=N<=25).It represents princess is N year(s) old.

输出格式

For each test case,output the profile of the gift.
The uppercase letter of the level represents the jewelry box.
The first letter 'Z' in 'ZHI' represents the paper box.

输入样例

2
1
2

输出样例

A
AAAAA
AZZZA
AZBZA
AZZZA
AAAAA
 #include <stdio.h>
#include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char *argv[]) {
int t;
scanf("%d",&t); if(t==){
printf("A");
}else{
char box[*t-][*t-];
int j;
int k;
for(k=;k<*t-;k++){
box[][k]='A';
} for(k=;k<*t-;k++){
box[][k]='Z';
}
box[][]='A';
box[][*t-]='A'; int temp;
for(j=;j<*t-;j++){//上半部分
if((j%)==&&j!=){//偶数行
box[j][j-]='Z';
box[j][(*t-)-j]='Z'; for(k=j;k<(*t-)-j;k++){
box[j][k]=box[j-][k]+;
} for(k=;k<j;k++){
if(k!=((*t-)-j)&&k!=j-){
box[j][k]=box[j-][k];
}
}
for(k=(*t-)-j;k<*t-;k++){
if(k!=((*t-)-j)&&k!=j){
box[j][k]=box[j-][k];
}
} } if((j%)!=&&j!=){
for(k=;k<*t-;k++){
if(k!=j-&&k!=(*t-)-j){
box[j][k]=box[j-][k];
}else{
box[j][k]='A'+(j-)/;
}
}
}
}
temp=;
for(j=*t-;j<*t-;j++){
for(k=;k<*t-;k++){ box[j][k]=box[j-temp][k]; }
temp=+temp;
} for(k=;k<*t-;k++){
for(temp=;temp<*t-;temp++){
printf("%c",box[k][temp]);
printf("%s"," ");
}
printf("\n");
} }
return ;
}