#include <stdio.h>
#include <math.h>
int main ( )
{
for (int i = 1; i < 8; i++) {
printf(" ");
for (int j = 1 ; j <= fabs(4-i); j++) {
printf(" ");
}
for (int j = 1; j <= 2 * (4 - fabs(4-i)) - 1; j++) {
printf("* ");
}
printf("\n");
}
}
With a feeling of absolute value less
the following is not a
#include <stdio.h>
int main()
{
int i, j, k;
for (i = 1; i <= 4; i++)
{
for (j = 1; j <= (4 - i) + 5; j++)
{
printf(" ");
}
for (k = 1; k <= (2 * i - 1) + 5; k++)
{
if (k <= 5)
{
printf(" ");
}
else
{
printf(" * ");
}
}
printf("\n");
}
for (i = 1; i <= 3; i++)
{
for (j = 1; j <= i + 5; j++)
{
printf(" ");
}
for (k = 1; k <= (7 - 2 * i) + 5; k++)
{
if (k <= 5)
{
printf(" ");
}
else
{
printf(" * ");
}
}
printf("\n");
}
return 0;
}
the Output:
*
* * *
* * * * *
* * * * * * *
* * * * *
* * *
*
Program ended with Exit code: 0
friends, note the space, if it is the operating system, error-prone, it is blank spaces or blank spaces or blank spaces *
the number of lines too hurt