View Code of Problem 53

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
using namespace std;


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

}

Double click to view unformatted code.


Back to problem 53