Berikut codingannya:
#include<iostream>
using namespace std;
int main (){
int baris, spasi, bintang, a,b;
a=5;
b=1;
for (baris=1; baris<=a; baris++){
for (spasi=1; spasi<=a-baris; spasi++){
cout<<" ";
}
for (bintang=1; bintang<=baris; bintang++){
cout<<"* ";
}
cout<<endl;
}
for (baris=5; baris>=b; baris--){
for (spasi=5; spasi>=b+baris; spasi--){
cout<<" ";
}
for (bintang=1; bintang<=baris; bintang++){
cout<<"* ";
}
cout<<endl;
}
return 0;
}
Hasilnya:
0 Comments