#include <iostream.h>
#include <conio.h>
int main() {
int i,j, lebar = 5, tinggi = 5,diameter = 5;
cout << "masukan jumlah : ";
cin>>diameter;
cout << endl;
lebar = 4 * diameter - 1;
tinggi = 3 * diameter;
cout << "lebar : " << lebar << endl;
cout << "tinggi : " << tinggi << endl;
cout <<endl;
for (i = 0; i < tinggi; i++) {
for (j = 0; j < lebar; j++) {
if ((i < (tinggi / 3)) && ((j >= (lebar / 2) - i)
&& (j <= (lebar / 2) + i))) {
cout << '*';
}
else if (((i >= (tinggi / 3)) && (i <= (tinggi - diameter)))
&& ((j >= i - diameter) && ((j < lebar - (i - diameter))))) {
cout << '*';
}
else if (((i > tinggi - diameter)&&((j >= diameter )
&&(j < lebar-diameter)))&&((j <= (lebar / 2) - (i - diameter*2))
||(j >= (lebar / 2) + (i - diameter*2)))) {
cout <<"*";
}
else {
cout << " ";
}
}
cout << endl;
}
getch();
}
0 comments:
Post a Comment