Today, when I was writing code, I found a problem.
When I press enter, I find that the symbol is removed. I've tried it many times, and it's true.
I can't delete "*" so that line change.
This is my code:
#include<stdio.h>
int main()
{
int i, j, k;
int number;
int x ;//中间数
scanf("%d",&number);
x=( number / 2 )+ 1;
for (i = 1; i <= x; i++)//第一层循环是打印换行
{
//为什么是x-i?在*之前其实是有六个空格的
for (j = x-i; j >0; j--)//第二层打印空格
{
printf(" ");//两个空格
}
for (k = 0; k < (2*i-1); k++)//第三层打印符号
{
printf("* ");
}
printf("\n");
}
for (i = 1; i < x; i++)//打印三个换行符
{
for (j = 0; j < i; j++)
{
printf(" ");
}
for (k = (x - i) * 2 - 1;k>0;k--)
{
printf("* ");
}
printf("\n");
}
return 0;
}
attention: the code is c language.