menu
Sabtu, 09 April 2016
Algoritma dan program Permutasi nPr
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int faktorial(int x){
int i=1, f;
f=1;
while(i<=x){
f=f*i; i++;
} return (f);
}
int main(int argc, char** argv) {
int n, r, p, permutasi;
cout<<"Menghitung Permutasi "<<endl;
cout<<"Masukkan nilai n = "; cin>>n;
cout<<"Masukkan nilai r = "; cin>>r;
p=n-r;
permutasi=faktorial(n)/faktorial(p);
cout<<"Hasil Permutasi nPr = "<<permutasi;
return 0;
}
Raptor:
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar