标签:amp oid include lse 输入 void print 菱形 else
#include"stdio.h"
void main()
{
int i,j,n;
printf("请输入菱形行数(行数必须为奇数):");
scanf("%d",&n);
if(n%2!=0)
{
for(i=1;i<n+1;i++)
{
if(i<n/2+2)
{
for(j=0;j<n/2+1-i;j++)
{
printf(" ");
}
for(j=0;j<2*i-1;j++)
{
printf("*");
}
}
else
{
for(j=0;j<i-(n/2+1);j++)
{
printf(" ");
}
for(j=0;j<(n-i)*2+1;j++)
{
printf("*");
}
}
printf("\n");
}
}
else
printf("请您输入奇数!");
}
标签:amp oid include lse 输入 void print 菱形 else
原文地址:https://www.cnblogs.com/bobotongxue/p/12306708.html