#include <iostream.h>
#include <stdio.h>
#include <conio.h>
long int fak (long int x);
void main()
{
int y,z, Prts,pilihan,s;
char ulang;
do
{
cout<<"===>Raisa Dwi Selviani Hermansyah<==="<<endl<<endl;
cout<<"|*****************************|"<<endl;;
cout<<"|PROGRAM PERHITUNGAN PERMUTASI|"<<endl;
cout<<"|*****************************|"<<endl;;
cout<<"|1. PERMUTASI |"<<endl;
cout<<"|2. KELUAR |"<<endl;
cout<<"|*****************************|";
cout<<endl<<endl;
cout<<" Pilih Angka : ";cin>>pilihan; cout<<endl;
switch (pilihan)
{
case 1 :
cout<<" Program Menghitung Permutasi(yPz)";
cout<<endl;
cout<<" Masukkan Nilai y : "; cin>>y;
cout<<endl;
cout<<" Masukkan Nilai z : "; cin>>z;
cout<<endl;
if (y>z)
{
Prts = fak (y)/fak(y-z);
cout<<endl;
printf(" Permutasinya adalah: %d",Prts);
cout<<endl;
}
else if (y<z)
{
cout<<"data salah";}
cout<<endl ;
break;
case 2 :
cout<<"*****Bye Bye*****"<<endl<<endl;
break;
default:
cout<<"Fatal Error, Please Wait..."<<endl<<endl;
break;
}
cout<<"Back to Main Menu (y/n)?";cin>>ulang;
cout<<endl<<endl<<endl<<endl;
}
while(ulang == 'y');
}
getch();
long int fak (long int y)
{
int f;
if (y<=1)
{
f=1;
}
else
{
f=y*fak(y-1);
}
return (f);
}
#include <stdio.h>
#include <conio.h>
long int fak (long int x);
void main()
{
int y,z, Prts,pilihan,s;
char ulang;
do
{
cout<<"===>Raisa Dwi Selviani Hermansyah<==="<<endl<<endl;
cout<<"|*****************************|"<<endl;;
cout<<"|PROGRAM PERHITUNGAN PERMUTASI|"<<endl;
cout<<"|*****************************|"<<endl;;
cout<<"|1. PERMUTASI |"<<endl;
cout<<"|2. KELUAR |"<<endl;
cout<<"|*****************************|";
cout<<endl<<endl;
cout<<" Pilih Angka : ";cin>>pilihan; cout<<endl;
switch (pilihan)
{
case 1 :
cout<<" Program Menghitung Permutasi(yPz)";
cout<<endl;
cout<<" Masukkan Nilai y : "; cin>>y;
cout<<endl;
cout<<" Masukkan Nilai z : "; cin>>z;
cout<<endl;
if (y>z)
{
Prts = fak (y)/fak(y-z);
cout<<endl;
printf(" Permutasinya adalah: %d",Prts);
cout<<endl;
}
else if (y<z)
{
cout<<"data salah";}
cout<<endl ;
break;
case 2 :
cout<<"*****Bye Bye*****"<<endl<<endl;
break;
default:
cout<<"Fatal Error, Please Wait..."<<endl<<endl;
break;
}
cout<<"Back to Main Menu (y/n)?";cin>>ulang;
cout<<endl<<endl<<endl<<endl;
}
while(ulang == 'y');
}
getch();
long int fak (long int y)
{
int f;
if (y<=1)
{
f=1;
}
else
{
f=y*fak(y-1);
}
return (f);
}
Tidak ada komentar:
Posting Komentar