#include <iostream.h>
#include <conio.h>
int main()
{
int i, j, tinggi;
cout<<("input : ");
cin>>tinggi;
for(i = 2; i <= tinggi; i++) {
cout<<"";
for(j =1; j <= tinggi - i; j++) {
cout<<" ";
}
for(j =1; j <= i; j++) {
cout<<"*";
for(j=3;j<=i;j++){
cout<<" ";
}
}
for(j =2; j <= i-1; j++) {
for(j=3;j<=i-1;j++){
cout<<" ";
}
cout<<"*";
}
cout<<"\n";
}
cout<<"*";
for(i=2;i<=tinggi;i++)
{
cout<<"*";
cout<<"*";
}
getch();
}
#include <conio.h>
int main()
{
int i, j, tinggi;
cout<<("input : ");
cin>>tinggi;
for(i = 2; i <= tinggi; i++) {
cout<<"";
for(j =1; j <= tinggi - i; j++) {
cout<<" ";
}
for(j =1; j <= i; j++) {
cout<<"*";
for(j=3;j<=i;j++){
cout<<" ";
}
}
for(j =2; j <= i-1; j++) {
for(j=3;j<=i-1;j++){
cout<<" ";
}
cout<<"*";
}
cout<<"\n";
}
cout<<"*";
for(i=2;i<=tinggi;i++)
{
cout<<"*";
cout<<"*";
}
getch();
}
coding 2: coding persis kayak java :)
#include <iostream.h>
#include <conio.h>
int main()
{
int n;
int a, b=0, c, d, e;
cout<<("input : ");
cin>>n;
a = n;
e = n-1;
for(c=1;c<=n;c++){
b = 1;
for(d=1;d<=a;d++) {
if (b<=e) {
cout<<" ";
b++;
} else {
if(d==b||d==a||e==0){
cout<<"*";
}else
cout<<" ";
}
}
e--;
a++;
cout<<"\n";
}
getch();
}