Code:
#include
int main () {
int x ,i, n , j ;
cout << "Enter the base width of triangle to draw. \n";
cin>>x;
for(j=1;j<=x;j++)
{ if(j==x)
{ for(i=1;i<=2*x-1;i++)
if(i%2!=0) cout<<("*");
else cout<<(" ");
cout<<("\n");
break;
}
for(n=1;n<=x-j;n++)
cout<<(" ");
for(i=1;i<=2*j-1;i++)
if(i==1 || i==2*j-1) cout<<("*");
else cout<<(" ");
cout<<("\n"); }
return (0); }
*Kacode.org



Tidak ada komentar:
Posting Komentar