#include
#include
#pragma argsused
int main()
{
int n,baris,i,j,k;
cout<<"+++++Membuat Bentuk Segitiga+++++"<
cin>>n;
cout<
{
baris=n-1;
for (i=1;i<=n;i++)
{
for (j=1;j<=baris;j++) cout<<" ";
for (k=1;k<=i;k++) cout<<"* ";
cout<
}
}
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=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<
}
for(i=1;i<=n;i++) cout<<"* "; // Tutup Bawah segitiga
}
getch();
}
Tidak ada komentar:
Posting Komentar