Monday, April 16, 2012
DIAMOND
#include <iostream.h>
#include <conio.h>
int main()
{
loop:
int ganjil,i,j;
clrscr();
cout<<"\n\n\t\t\tPROGRAM DIAMOND BINTANG DENGAN C++\n";
cout<<"\t\t\t\tPATRICIA DIANITA WIJAYA\n";
cout<<"\t\t\tpatriciadianitawijaya.blogspot.com\n\n";
do
{
cout<<"Masukkan bilangan ganjil (1-19): ";
cin>>ganjil;
if(ganjil%2==0)
cout<<"Yang harus anda masukkan ialah angka ganjil\n\n";
}while(ganjil%2==0);
for( i=0; i<=ganjil; i+=2)
{
for( j=0; j<ganjil-i;j+=2)
{
cout<<" ";
}
for(int z=0;z<=i;z++)
{
cout<<"*";
}
cout<<endl;
}
ganjil = ganjil - 2;
for( i=0; i<ganjil; i+=2)
{
for( j=0; j<=i+2;j+=2)
{
cout<<" ";
}
for(int z=1;z<=ganjil-i;z++)
{
cout<<"*";
}
cout<<endl;
}
cout<<"Tekan <enter> untuk mengulang";
getch();
goto loop;
return 0;
}
Labels:
Algoritma dan Pemrograman
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment