Advertisement
sellmmaahh

popravni-2013-zad6

Jul 28th, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cmath>
  4. const double PI(4*atan(1));
  5.  
  6.  
  7. using namespace std;
  8.  
  9. double *pok (double f(double), double xmin, double xmax, double dx=1)
  10. {  int duzina=xmax-xmin;
  11.     double *niz=new double [duzina];
  12.     int i(xmin), j(0);
  13.     while(i<=xmax && j<duzina)
  14.     {
  15.         niz[j]=f(i);
  16.         j++;
  17.         i+=dx;
  18.     }
  19.  
  20.     return niz;
  21. }
  22. int main () {
  23. double x{0};
  24. double y{10};
  25. double korak(1);
  26. double *rez{pok([](double a) {return a*a*a;},x,y,korak)};
  27. for (int i=0; i<y-x; i++)
  28.     cout<<rez[i]<<' ';
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement