实心的:
#include<stdio.h>
int n
void draw(int n)
{
int i,j
for (i=1-(n>>1)i<=ni++)
if (i>=0)
{
for (j=0j<ij++) printf(" ")
for (j=1j<=2*(n-i)+1j++) printf(" *")
printf("\n")
}
else
{
for (j=ij<0j++) printf(" ")
for (j=1j<=n+2*i+1j++) printf(" *")
for (j=1j<=-1-2*ij++) printf(" ")
for (j=1j<=n+2*i+1j++) printf(" *")
printf("\n")
}
}
int main()
{
printf("Please input the size (n>=4):")
scanf("%d",&n)
draw(n)
return 0
}
空心的:
#include<stdio.h>
int n
void draw(int n)
{
int i,j
for (i=1-(n>>1)i<=ni++)
if (i>0)
{
for (j=0j<ij++) printf(" ")
for (j=1j<=2*(n-i)+1j++)
if (j==1||j==2*(n-i)+1) printf(" *")
else printf(" ")
printf("\n")
}
else
if (i==0)
{
printf(" *"返迹)
for (j=1j<nj++) printf(" ")
printf(" *")
for (j=1j<nj++) printf(" ")
printf(" *\n")
}
else
{
for (j=ij<0j++) printf(" ")
for (j=1j<=n+2*i+1j++)
if (i==1-(n>>1)) printf(" *")
else if (j==1||j==n+2*i+1) printf(" *")
else printf(" ")
for (j=1j<=-1-2*ij++) printf(" ")
for (j=1j<=n+2*i+1j++)
if (i==1-(n>>1)) printf(" *")
else if (j==1||j==n+2*i+1) printf(" *")
else printf(" ")
printf("\n")
}
}
int main()
{
printf("Please input the size (n>=4):")
scanf("%d",&n)
draw(n)
return 0
}
#include<stdio.h>int main()
{
int i,j,k,l,m
char c='*'
for(i=1i<=5i++)
printf("\n")
for(i=1i<4i++)
{
for(j=1j<27-i*2j++)
printf(" ")
for(k=1k<=i*4+1k++)
printf("%c",c)
for(l=1l<=9-4*(i-1)l++) 念搜返
printf(" ")
for(m=1m<=i*4+1m++)
printf("%c",c)
printf("\n")
}
仔饥for(i=1i<4i++)
{
for(j=1j<20j++)
printf(" ")
for(k=1k<=29k++)
printf("%c",c)
printf("\n")
}
for(i=1i<8i++)
{
for(j=1j<20+2*ij++)
printf(" ")
for(k=1k<=29-4*ik++)
printf("%c",c)
漏凯 printf("\n")
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)