View Code of Problem 53

#include<stdio.h>
#include<math.h>
int main(){
	int n;
	scanf("%d",&n);
	int i,j,k;
	for(i=1;i<n+1;i++){
		for(j=1;j<n-i+1;j++){
			printf(" ");
		}
			for(k=1;k<(2*i);k++){
		if(k==(2*i-1)){
		printf("*\n");
		}else{
		printf("*");	
		}
	}
	}

	for(i=1;i<n;i++){
		for(j=1;j<=i;j++){
			printf(" ");
		}
			for(j=1;j<(n-i)*2;j++){
			if(j==((n-i)*2-1)){
				printf("*\n");
			}else{
				printf("*");
			
		}
	}
	
	}
	
	
}

Double click to view unformatted code.


Back to problem 53