View Code of Problem 53

#include <stdio.h>
#include <math.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    int n;
    
    scanf("%d", &n);
    
    for(int i = 1, k = 1; i <= n; i++, k += 2) {
        for(int j = 0; j < n - i; j++) {
            printf(" ");
        }
        for(int l = 0; l < k; l++) {
            printf("*");
        }
        printf("\n");
    }
    
    for(int i = n - 1, k = 2 * (n - 1) - 1; i >= 1; i--, k -= 2) {
        for(int j = 0; j < n - i; j++) {
            printf(" ");
        }
        for(int l = 0; l < k; l++) {
            printf("*");
        }
        printf("\n");
    }
}

Double click to view unformatted code.


Back to problem 53