View Code of Problem 53

#include<stdio.h>
#include<string.h>
int main(){
	char a[100];
	int i,len,k,j;
	scanf("%d",&k);
	for(i=1;i<=k;i++){
		for(j=i;j<=k-1;j++){
			printf("%c",' ');
		}
		for(j=1;j<=2*i-1;j++){
			printf("%c",'*');
		}
		printf("\n");
	}
	for(i=k-1;i>=1;i--){
		for(j=i;j<=k-1;j++){
			printf("%c",' ');
		}
		for(j=1;j<=2*i-1;j++){
			printf("%c",'*');
		}
		printf("\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 53