Difference between revisions of "Cppreference:Archives"
From cppreference.com
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
#include <iostream> | #include <iostream> | ||
using namespace std; | using namespace std; |
Revision as of 04:01, 16 January 2020
- include <iostream>
using namespace std; int main() { int i, factn=1, n, k, factnk=1, comb; cout<<"n="; cin>>n; cout<<"k="; cin>>k; if(n<k){ cout<<"Nu exista factorial!";} else{
for(i=1;i<=n;i++){ factn=factn*i; }
for(i=1; i<=n-k; i++){ factnk=factnk*i; }
if(n!=0)
{
comb=factn/factnk;
}
cout<<"Permutari de "<<n<<" luate cate "<<k<<" = "<<comb;
}
}