#include <stdio.h>
void printZorro(int n)
{
int i;
char alph[26];
for(int k=0;k<26;k++)
{
alph[k] = (char )('a' + k);
}
for(i = 0;i<n;i++)
printf("%c",alph[i%26]);
printf("\n");
for(int p=1;p<n-1;p++)
{
for(int q=0;q<n-p-1;q++)
printf(" ");
printf("%c\n",alph[i%26]);
i++;
}
for(int j=0;j<n;j++)
{
printf("%c",alph[i%26]);
i++;
}
//printf("\n");
}
int main()
{
int time ;
scanf("%d",&time);
while(time != 0)
{
printZorro(time);
printf("\n");
scanf("%d",&time);
if(time != 0)
printf("\n");
}
return 0;
}
算法没有技术含量,关键是这个输出有点恶心,刚开始没有看到那个hint
另外:
vc和oj上的编译器不一样,vc中在for语句中声明的变量i,在下一个for语句中还能用。但是在oj上不能,所以必须把i声明成函数的内部变量