Advertisement
Guest User

Tutorial 7, Zadatak 5, TP

a guest
May 29th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <functional>
  3. using namespace std;
  4. int f(int x)
  5. {
  6.     return x +2;
  7. }
  8. function<int(int)> IteriranaFunkcija(int f(int), int n)
  9. {
  10.  
  11.         return [f,n] (double x) {int i(0); while(i < n){x = f(x);i++;} return x;};
  12.  
  13. }
  14. int main()
  15. {
  16.     auto g(IteriranaFunkcija(f, 2));
  17.     cout << g(5);
  18.  
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement