<散分> 我一直不会打印菱形块,今天终于弄出来了,也许有需要的同学 直接copy代码吧
程序代码:#include<stdio.h>
#define N 9
int main()
{
int row=1,col=0;
int s;
char ch='a';
for(row=1;row<=(2*N-1);row++)
{
if(row<N)
{
for(s=0;s<2*N-row;s++) printf("%2c",0x20);
for(col=0;col<2*row-1;col++)
{
if(col<row-1) printf("%2c",ch++); else printf("%2c",ch--);
}
}
else
{
for(s=0;s<row;s++) printf("%2c",0x20);
for(col=2*(row-N);col<2*N-1;col++)
{
if(col<row-1) printf("%2c",ch++); else printf("%2c",ch--);
}
}
printf("\n");
ch='a';
}
return 0;
}效果图:a
a b a
a b c b a
a b c d c b a
a b c d e d c b a
a b c d e f e d c b a
a b c d e f g f e d c b a
a b c d e f g h g f e d c b a
a b c d e f g h i h g f e d c b a
a b c d e f g h g f e d c b a
a b c d e f g f e d c b a
a b c d e f e d c b a
a b c d e d c b a
a b c d c b a
a b c b a
a b a
a
[ 本帖最后由 wp231957 于 2012-12-19 23:03 编辑 ]









