该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#include int main(void)
{
int index, up, lines;
printf("请输入将要显示的行数:\n");
while(scanf("%d", &up) == 1)
{
if(up % 2 == 0)
{
for(lines = 1; lines <= up / 2; lines++)
{
for(index = 0; index < lines; index++)
printf("*");
for(index = 0; index < up - 2 * lines; index++)
printf(" ");
for(index = 0; index < lines; index++)
printf("*");
printf("\n");
}
for(lines = up / 2 - 1; lines > 0; lines--)
{
for(index = lines; index > 0; index--)
printf("*");
for(index = 0; index < up - 2 * lines; index++)
printf(" ");
for(index = lines; index > 0; index--)
printf("*");
printf("\n");
}
}
else
{
for(lines = 0; lines <= up / 2; lines++)
{
for(index = 0; index < lines; index++)
printf("*");
for(index = 0; index < up - 2 * lines; index++)
printf(" ");
for(index = 0; index < lines; index++)
printf("*");
printf("\n");
}
for(lines = up / 2; lines > 0; lines--)
{
for(index = lines; index > 0; index--)
printf("*");
for(index = 0; index < up - 2 * lines; index++)
printf(" ");
for(index = lines; index > 0; index--)
printf("*");
printf("\n");
}
}
printf("请输入一个新的行数:\n");
}
system("PAUSE");
return 0;
}
这次就帮你写了(实际只是作为新手的自己想要练练手
),这种题目还是自己想想的比较好,这算是最基础的了