Full Pyramid
Limits
1s, 512 MB
Given an integer N, print a full pyramid of asterisks.
A full pyramid of asterisks of size N has N lines of asterisks. The first line has 1 asterisk, the second line has 2 asterisks, the third line has 3 asterisks and so on. Each asterisk has a space between them. The asterisks in each line are centered so as to make it look like a pyramid.
Here is a full pyramid of asterisks of size 4:
A full pyramid of asterisks of size N has N lines of asterisks. The first line has 1 asterisk, the second line has 2 asterisks, the third line has 3 asterisks and so on. Each asterisk has a space between them. The asterisks in each line are centered so as to make it look like a pyramid.
Here is a full pyramid of asterisks of size 4:
*
* *
* * *
* * * *
Input
The input will contain an integer N (0 < N < 100).
Output
Print the full pyramid of asterisks of the given size.
Do not print any space after the last asterisk in each line.
Do not print any space after the last asterisk in each line.
#include<stdio.h>
int main()
{
int i,j,n;
scanf("%d",&n);
for(i=0;i<n;i++)
{
for(j=i;j<n-1;j++)
{
printf(" ");
}
for(j=0;j<=i;j++)
{
if(j==i)
printf("*");
else
printf("* ");
}
printf("\n");
}
}