#include <iostream.h>
#include <conio.h>
void diagonalatas();
void diagonalbawah();
void silang();
void segitigaataskiri();
void segitigabawahkiri();
void segitigaataskanan();
void segitigabawahkanan();
void main(){
int menu;
do{
clrscr();
cout<<endl;
cout<<" MENU PILIHAN "<<endl;
cout<<"=============================="<<endl;
cout<<"1. diagonal bawah "<<endl;
cout<<"2. diagonal atas "<<endl;
cout<<"3. silang "<<endl;
cout<<"4. segitiga atas kiri"<<endl;
cout<<"5. segitiga bawah kanan"<<endl;
cout<<"6. segitiga bawah kiri "<<endl;
cout<<"7. segitiga atas kanan "<<endl;
cout<<"8. Keluar \n"<<endl;
cout<<"Masukkan Pilihan! :";cin>>menu;
switch (menu)
{
case 1: diagonalatas();break;
case 2: diagonalbawah();break;
case 3: silang();break;
case 4: segitigaataskiri();break;
case 5: segitigabawahkiri();break;
case 6: segitigaataskanan();break;
case 7: segitigabawahkanan();break;
}
}while (menu !=8);
getch();
}
void diagonalatas()
{
for(int i=1; i<=10; i++)
{
for(int n=1; n<i; n++)
{
cout<<" ";
}
cout<<"*"<<endl;
}
cout<<"\n"<<endl;
getch();
}
void diagonalbawah()
{
for(int n=1; n<10; n++)
{
for(int i=1; i<10-n; i++)
{
cout<<" ";
}
cout<<"*"<<endl;
}
cout<<"\n"<<endl;
getch();
}
void silang()
{
int baris, temp;
baris=10;
temp = baris;
for(int i=1; i<=baris; i++){
for(int j=1; j<=baris; j++){
if(j==i||j==temp)
cout << "* ";
else
cout << " ";
}
temp--;
cout << endl;
}getch();
}
void segitigaataskiri()
{
for(int i = 1; i <= 10; i++)
{
for (int j = 10; j >= i; j--)
cout<<'*';
cout<<endl;
}
getch();
}
void segitigabawahkiri()
{
int tinggi;
tinggi=10;
for(int i = 1; i <= tinggi; i++)
{
for (int j = 1; j <= i; j++)
{
cout<<"*";
}
cout<<" "<<endl;
}
getch();
}
void segitigaataskanan()
{
for(int k=1;k<=10;k++)
{
for(int l=10;l>=1;l--)
{
if(k+l<10)
{cout<<"*";}
else
{cout<<" ";}
}
cout<<endl;
}
getch();
}
void segitigabawahkanan()
{
for(int i=1;i<=10;i++)
{
for(int j=1;j<=10;j++)
{
if(i+j>10)
{cout<<"*";}
else
{cout<<" ";}
}
cout<<endl;
}
getch();
}
0 komentar:
Posting Komentar