----------------解决方案--------------------------------------------------------
真的很长见识,都很有创意的。尤其是宏定义
----------------解决方案--------------------------------------------------------
闲着无聊俺也写了一个:
程序代码:
#include <stdio.h>
#define ABS(x) ((x)>0?(x):(-(x)))
#define N 10
int main()
{
int i,j;
for(i=0;i<2*N-1;i++)
{
j=ABS(N-i-1);
printf("%*c%-*c\b*\n",j+1,' ',2*(N-j)-1,'*');
}
return 0;
}
[[it] 本帖最后由 VxWorks 于 2008-4-20 20:30 编辑 [/it]]
----------------解决方案--------------------------------------------------------
赞楼上
[color=white]
----------------解决方案--------------------------------------------------------
偶也玩一个
main(o,O,Q){o==1&&(o=(O=scanf("%d",&Q)-1)+2,Q+=2),printf("%*c%*c\n",Q-o+2,42,2*o-4,o-2?42:0),(O=o==Q-1?1:O)?main(o-1,O,Q):main(o+1,O,Q);}
请用TC
----------------解决方案--------------------------------------------------------
玩递归main有意思吗?不过是隐藏for循环中的显式迭代把程序变难看而已.
程序代码:
#include <stdio.h>
#define ABS(x) ((x)>0?(x):(-(x)))
#define N 10
int main(int i)
{return i<2*N? printf("%*c%-*c\b*\n",ABS(N-i)+1,' ',2*(N-ABS(N-i))-1,'*'),main(++i): 0;}
----------------解决方案--------------------------------------------------------
我是菜菜,看不懂。。。。看书去
----------------解决方案--------------------------------------------------------
可以输入随意数的代码:(vc++6.0编译通过)
#include<stdio.h>
int main(void)
{
int i, j, number;
printf("Input your number: ");
scanf("%i", &number);
for(i = 0; i < (2*number-1); ++i)
{
if( i < number -1)
{
for(j = 0; j < (2*number-1); ++j)
{
if( j == number-1 - i || j == number-1 + i )
printf("*");
else
printf(" ");
}
printf("\n");
}
else if( i == number -1)
{
for( j = 0; j < (2*number-1); ++j)
{
if( j == number-1-i || j == number-1 +i )
printf("*");
else
printf(" ");
}
printf("\n");
}
else
{
for( j = 0; j < (2*number-1); ++j)
{
if( ((i - number) == (j-1)) || ((i - number) == ( 2*number-3 - j)) )
printf("*");
else
printf(" ");
}
printf("\n");
}
}
return 0;
}
----------------解决方案--------------------------------------------------------
楼上要继续加强学习
[color=white]
----------------解决方案--------------------------------------------------------
???
----------------解决方案--------------------------------------------------------