Code
#include <iostream>
using namespace std;
int main()
{
int i,j,r;
cout << " Input number of rows : ";
cin >> r;
for(i=1;i<r;i++)
{
for(j=0;j<=r-i;j++)
cout<<"*";
for(j=2;j<=2*i-1;j++)
cout<<" ";
for(j=0;j<=r-i;j++)
cout<<"*";
cout<<endl;
}
for(i=r-1;i>=1;i--)
{
for(j=0;j<=r-i;j++)
cout<<"*";
for(j=2;j<=2*i-1;j++)
cout<<" ";
for(j=0;j<=r-i;j++)
cout<<"*";
cout<<endl;
}
cout<<endl;
return 0;
}
Output:
No comments:
Post a Comment