#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int a,b,c,n;
cout <<”masukan tinggi bintang = “;
cin<<n;
for( a=1; a<=n; a++)
{ for ( b=1; b<=n-a; b++)
cout<<” “;
for( c= 1; c<=a; c++)
cout<<”* “; cout<<endl;}
getch();
}
2. SEGITIGA PYRAMID KEBALIK
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int a,b,c,n;
cout <<”masukan tinggi bintang = “;
cin<<n;
for( a=1; a<=n; a++)
{ for ( b=1; b<=a; b++)
cout<<” “;
for( c= a; c<=n-a; c++)
cout<<”* “; cout<<endl;}
getch();
}
3. SEGITIGA SIKU-SIKU

#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int a,b,c,n;
cout <<”masukan tinggi bintang = “;
cin<<n;
for( a=1; a<=n; a++)
{ for ( b=1; b<=a; b++)
cout<<”*“; cout<<endl;}
getch();
}
4. SEGITIGA SIKU-SIKU KEBALIK

#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int a,b,c,n;
cout <<”masukan tinggi bintang = “;
cin<<n;
for( a=1; a<=n; a++)
{ for ( b=a; b<=n; b++)
cout<<”*“; cout<<endl;}
getch();
}
Catatan : perhatikan spasi yang ada dalam tanda petik contoh : ( "*spasi" ) dan ( "spasi") karena spasi mempengaruhi bentuk dari segitiga
Tidak ada komentar:
Posting Komentar