Posted in Programming

Pemrograman C++ : Program Permutasi dan Kombinasi



#include “iostream.h”
#include “conio.h”

int n, r, perm, comb;
void input(int &n, int &r){
cout<<“Input nilai dari n : “; cin>>n;
cout<<“Input nilai dari r : “; cin>>r;
int faktorial(int n){
if (n==0 || n==1){
return 1;
return (n*faktorial(n-1));
void permutasi(int n, int r, int &perm){
perm = faktorial(n)/faktorial(n-r);
void kombinasi(int n, int r, int &comb){
comb = faktorial(n)/(faktorial(n-r)*faktorial(r));
void proses(int n, int r, int &perm, int &comb){
void output(int perm, int comb, int n, int r){
cout<<“Hasil permutasinya adalah : “<<endl<<“P(“<<n<<“,”<<r<<“) = “<<perm<<endl;
cout<<“Hasil kombinasinya adalah : “<<endl<<“C(“<<n<<“,”<<r<<“) = “<<comb;
int main(){
int input_n, input_r, p, k;
input(input_n, input_r);
while (input_n < input_r){
cout<<“Tidak dapat diproses, masukkan nilai n lebih besar dari r!”<<endl;
input(input_n, input_r);
proses(input_n, input_r, p, k);
output(p, k, input_n, input_r);



I'm just a simple guy..

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s