//PROGRAM bintang
#include
#include
#pragma argsused
int main()
{
int n,baris,i,j,k,z;
cout<<"+++++Membuat Bentuk Segitiga+++++"< cout<<"================================="< cout<<"Masukkan jumlah level bintang : ";
cin>>n;
cout< if ((n<=3) && (n>=0))
{
baris=0;
z=n;
for (i=1;i<=n;i++)
{
for (j=1;j<=baris;j++) cout<<" ";
for (k=1;k<=z;k++) cout<<"* ";
cout< z=z-1;
baris=baris+1;
}
}
else
{
for(i=1;i<=n;i++) cout<<"* ";
cout< baris=1;
z=n-3;
for (i=1;i<=n-3;i++)
{
for (j=1;j<=baris;j++) cout<<" ";
cout<<"* ";
for (k=1;k<=z;k++) cout<<" ";
cout<<"*";
cout< z=z-1;
baris=baris+1;
}
z=2;
for (i=1;i<=2;i++)
{
for (j=1;j<=baris;j++) cout<<" ";
for (k=1;k<=z;k++) cout<<"* ";
cout< z=z-1;
baris=baris+1;
}
}
getch();
}
//PROGRAM bintang
#include
#include
#pragma argsused
int main()
{
int n,baris,i,j,k;
cout<<"+++++Membuat Bentuk Segitiga+++++"< cout<<"================================="< cout<<"Masukkan jumlah level bintang : ";
cin>>n;
cout< if ((n<3 amp="" n="">=0))
{
baris=n-1;
for (i=1;i<=n;i++)
{
for (j=1;j<=baris;j++) cout<<" ";
for (k=1;k<=i;k++) cout<<"* ";
cout< baris=baris-1;
}
}
else
{
baris=n-1;
for (i=1;i<=2;i++) // 2 baris awal segitiga
{
for (j=1;j<=baris;j++) cout<<" ";
for (k=1;k<=i;k++) cout<<"* ";
cout< baris=baris-1;
}
baris=n-3;
for (i=1;i<=n-3;i++)
{
for (j=1;j<=baris;j++) cout<<" ";
cout<<"* "; //Membentuk Segitiga kosong
for (k=1;k<=i;k++) cout<<" ";
cout<<"*";
cout< baris=baris-1;
}
for(i=1;i<=n;i++) cout<<"* "; // Tutup Bawah segitiga
}
getch();
}
3>