Advertisement
Pafnytiu

сумма Паши

Nov 24th, 2015
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. float function(float x,float e)
  6.  
  7. {float s,a; float n; s=0; n=2; a=1;
  8. while(fabs(a)>=e)
  9. {s+=a;
  10. a*=pow(-1,n)*((x*(1+n-2)*(4+n-2))/((2+n-2)*(5+n-2)));
  11. n++;}
  12. cout<<" "<<x<<" "<<s<<" "<<n-2<<endl;
  13. return 0;
  14. }
  15. float main()
  16.  
  17. { int n,i;
  18. float e,s;
  19. setlocale(LC_ALL, "Russian");
  20. cout<<"№ "<<"Значение X "<<"Значение функции F(x) "<<"Количество просуммированных слагаемых n "<<endl;
  21.  
  22. cin>>e;
  23. i=1;
  24.  
  25. for(float x=0.1;x<=1;x+=0.1)
  26. {cout<<i<<"\t";
  27. function(x,e);
  28. i++;}
  29. system("pause");
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement