Output isosceles triangle pattern

Enter a positive integer n ( . 1 ≤n≤ . 9 ), a print height of n, the "*" composed of an isosceles triangle pattern. When n = 3, the output follows a pattern of an isosceles triangle:

 ***** 
 *** 
  *
 
#include <stdio.h>
int main(void)
{
    int i, j, n;

    scanf("%d", &n);
    for (i = n; i > 0; i--)
    {
        for (j = i; j < n; j++)
        {
            printf(" ");
        }
        for (j = 1; j <= i * 2 - 1; j++)
        {
            printf("*");
        }
        printf("\n");
    }

    getchar();
    getchar();
    return 0;
}

 

Guess you like

Origin www.cnblogs.com/2018jason/p/12441553.html