![](https://img-blog.csdnimg.cn/img_convert/ae14096cf7f83655c6bcd032773db496.png)
用*围城菱形的程序设计报告
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,n;
clrscr(); //to clear the screen
printf(“How many lines:”);
scanf(“%d”,&n);
n*=2;
printf(“n”);
for(i=1;i<n;i+=2)
{
for(j=n-1;j>i;j-=2)
printf(” “);
for(k=1;k<=i;++k)
{
if(i==n-1)
printf(“*”);
else
if(k==1||k==i)
printf(“*”);
else
printf(” “);
}
printf(“n”);
}
getch(); //to stop the screen;
}
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,n;
clrscr(); //to clear the screen
printf(“How many lines:”);
scanf(“%d”,&n);
n*=2;
printf(“n”);
for(i=1;i<n;i+=2)
{
for(j=n-1;j>i;j-=2)
printf(” “);
for(k=1;k<=i;++k)
{
if(i==n-1)
printf(“*”);
else
if(k==1||k==i)
printf(“*”);
else
printf(” “);
}
printf(“n”);
}
getch(); //to stop the screen;
}
翻译自: https://www.thecrazyprogrammer.com/2012/07/c-program-to-produce-following-design.html
用*围城菱形的程序设计报告