Advertisement
sellmmaahh

popravni-2014-zad5-f(f(f(f(n))))

Jul 31st, 2015
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <stdexcept>
  4. #include <functional>
  5.  
  6.  
  7. using namespace std;
  8.  
  9. template < typename T, typename FunkTip>
  10. auto Fja(T x,FunkTip f, int n)->decltype (x)
  11.  {
  12.  auto rez=f(x);
  13. for (int i=1; i<=n; i++) {
  14.    rez=f(rez);
  15. }
  16. return rez;
  17. }
  18.  
  19.  
  20.  
  21. int main () {
  22. cout<<Fja(10, [] (int x) {return 3*x*x-5;} ,5);
  23.  
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement