Bangun Ruang
__________________________________________________________
#include<iostream.h>
#include<conio.h>
void segitiga();
void kotak();
main()
{
int a,c;
char pil;
do
{
cout<<"pilihan pilihan bangun ruang\n";
cout<<"1. segitiga\n";
cout<<"2. kotak bolong\n";
cout<<"masukkan pilihan ? ";
cin>>a;
if(a==1)
{
segitiga();
}
else if(a==2)
{
kotak();
}
else
{cout<<"salah bos sorry\n";
}
cout<<"apa anda ingin mengulang (y/t)?? ";
cin>>pil;
}
while (pil=='y');
cout<<"terima kasih";
}
void segitiga()
{
int a,b,c,d,z=1;
for(a=1;a<=5;a++)
{cout<<" ";
}
cout<<"*";
cout<<endl;
for(a=1;a<=4;a++)
{for(b=4;b>=a;b--)
{cout<<" ";}
cout<<"*";
for(c=1;c<=z;c++)
{cout<<" ";}
z=z+2;
cout<<"*";
cout<<endl;
}
for(a=1;a<=6;a++)
{cout<<"* ";
}
cout<<endl;
}
void kotak()
{int a,b,c,d;
for(a=1;a<=10;a++)
{cout<<"*";
}
cout<<endl;
for(b=1;b<=5;b++)
{cout<<"*";
for(c=1;c<=8;c++)
{cout<<" ";}
cout<<"*";
cout<<endl;
}
for(a=1;a<=10;a++)
{cout<<"*";
}
cout<<endl;
}
______________________________________________________
Semoga Berguna (y)
No comments:
Post a Comment