permutation c++

I am posting this response also includes the results of my exam yesterday as discrete mathematics.

Please know the following is the calculation formula of permutations:

sourcecode:

#include <iostream.h>
#include <conio.h>

class per{
public:
masukan();
proses();
private:
int n,r,i;
int faktorn,faktorr;
};

per::masukan(){
cout<<"\t\tProgram Permutasi "<<endl;
cout<<"Masukan n = ";
cin>>n;
cout<<"Masukan r = ";
cin>>r;
}
per::proses(){
faktorn=1,faktorr=1;
for(i=n;i>0;i--){
faktorn=faktorn*i;
}
for(i=n-r;i>0;i--){
faktorr=faktorr*i;
}
cout<<"Permutasinya "<<faktorn/faktorr<<endl<<endl;
cout<<"https://yusufruli.wordpress.com";
}

int main(){
per x;
x.masukan();
x.proses();

getch();
return 0;
}

Posted on Juli 8, 2011, in Alprog. Bookmark the permalink. Tinggalkan komentar.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout /  Ubah )

Foto Google+

You are commenting using your Google+ account. Logout /  Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout /  Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout /  Ubah )

Connecting to %s

%d blogger menyukai ini: