题目错了吧,如果你输入偶数就不会有◇啊,只有这个题目
由键盘输入正数n,要求输出2*n+1行的菱形图案,要求菱形左边紧靠屏幕左边
#include "stdio.h"
main()
{ int i,j;
int n;
scanf("%d",&n);
for(i=0;i<=n+1;i++)
{ for(j=n-i;j>=0;j--)
printf(" ");
for(j=0;j printf("* ");
printf("\n"); }
for(i=0;i
for(j=n-i;j>0;j--)
printf("* ");
printf("\n"); }
getch();
}
---------------------------------
# include
# include
void main()
{
int i,j,a,b,n;
printf("please enter size");
scanf("%d",&n);
for(i=1;i
for(j=1;j<=n+i-1;j++)
if(j==n-i+1 ||j==n+i-1)
printf("*");
else
printf(" ");
printf("\n");
}
for(i=1;i<=2*n-1;i++)
printf("*");
printf("\n");
for(a=1;a
for(b=1;b<=2*n-a-1;b++)
if(b==n-(n-a-1)||b==2*n-a-1)
printf("*");
else
printf(" ");
printf("\n");}
}
--------------------------------------------------
结果
please enter size 15
------------------------------
*
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
*****************************
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
* *
*
Press any key to continue