Facebook
From Agata, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 296
  1. #include<iostream>
  2. #include<cmath>
  3. #include<cstdlib>
  4. using namespace std;
  5. long long silnia(int n)
  6. {
  7.         long long b;
  8.         b=1;
  9.         while(n>0)
  10.         {
  11.                 b=n*b;
  12.                 n=n-1;
  13.         }
  14.         return b;
  15. }
  16. int main()
  17. {
  18.         int n,k,x;
  19.         cout<<"Podaj dwie liczby: "<<endl;
  20.         cin>>n>>k;
  21.         if(n==0||k==0)
  22.         {
  23.                 cout<<"Zle liczby. Podaj liczby wieksze od 0. ";
  24.                 cin>>n>>k;
  25.         }
  26.         x=n-k;
  27.         cout<<((silnia(n))/(silnia(k)*silnia(x)))<<endl;
  28.         system("pause");
  29.         return 0;
  30. }