Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <iostream>
- #include <cmath>
- using namespace std;
- float my_func(float x,float eps)
- { float r=0.0 , a=2*x ;
- r=a ;
- for( int i=0 ; abs(a)>eps ; ++i)
- { a=a*2*x/(i+1) ;
- r*=a ;
- }
- return r;
- }
- void print(float const* const pb,float const* const pe,float eps,float(*pf)(float,float))
- {
- for (float const*p=pb ; p!=pe ; ++p)
- {
- std::cout << *p << '\t' ;
- }
- std::cout << '\n' ;
- for (float const* p=pb ; p!=pe ; ++p) {
- std::cout << pf(*p , eps) << '\t' ;
- }
- }
- int main()
- {
- float x[]={1.7,0 ,3.0,4,5};
- print(x, x+sizeof(x)/sizeof(x[0]),0.0001,&my_func);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement