#include<iostream.h>
#include<conio.h>
void main()
{
int i,j,k,n,temp;
cout<<"Enter height (must be >2) : ";
cin>>temp;
n=(temp/2)+1;
if(temp>2)
{
for(i=1,j=n-1;i<n,j>=0;i++,j--)
{
for(k=0;k<=j;k++)
cout<<" ";
for(k=1;k<=2*i-1;k++)
cout<<"*";
cout<<endl;
}
for(i=n-1,j=0;i>=0,j<n;i--,j++)
{
cout<<" ";
for(k=0;k<=j;k++)
cout<<" ";
for(k=1;k<=2*i-1;k++)
cout<<"*";
cout<<endl;
}
}
else
cout<<"Minimum should be 3";
getch();
}
Output
No comments:
Post a Comment