#include iostream
#include conio.h
#include math.h
using
namespace std;
int main
()
{
int num, a, b, i, j, x, y;
cout << "** Gambar **"
<< endl;
cout << "\nMasukkan angka ganjil
= ";
cin >> num;
if (num % 2 == 1)
{
a = num / 2;
b = a;
x = 1;
y = a + 1;
}
else
{
cout << "oups, Anda tidak
memasukkan angka ganjil";
cout << endl;
cout << endl;
system("PAUSE");
return 0;
}
for (i = 1; i <= num; i++)
{
for (j = 1; j <= a; j++){
cout << "* ";
}
for (j = 1; j <= x; j++){
if ( j % 2 == 0)
cout << " ";
else
cout << "* ";
}
for (j = 1; j <= b; j++){
cout << "* ";
}
if (i < y){
a--;
b--;
x = x + 2;
}
else{
a++;
b++;
x = x - 2;
}
cout << "\n";
}
getch();
return 0;
Tidak ada komentar:
Posting Komentar