Advertisement
Guest User

ASDprg1

a guest
Jun 25th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int newt (int n, int k) {
  5. if ( (k == 0) || ( k == n ) ) return 1;
  6. else return newt(n-1, k-1) + newt(n-1,k);
  7. }
  8.  
  9.  
  10. int main() {
  11. int n,k;
  12. std::cout<<"Podaj n: ";
  13. std::cin>>n;
  14. std::cout<<"Podaj k: ";
  15. std::cin>>k;
  16. cout << "Wynik: " << newt(n,k) << endl;
  17. return 0;
  18. }
  19.  
  20. //rekurencja
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement