Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <math.h>
- using namespace std;
- int main()
- {
- float xn, xk, dx, e, s, sum, x, F;
- int n=1,nf=1;
- cout<<"Vvedite xn, xk, dx, e: ";
- cin>>xn>>xk>>dx>>e;
- cout<<"------------------------------------------\n";
- cout<<"| x | f | n | F |\n";
- cout<<"------------------------------------------\n"<<endl;
- for(x=xn; x<=xk; x+=dx){
- n=0;
- sum=1;
- s=-x;
- sum+=s;
- F=pow(2.71828 ,-1*x);
- while(fabs(s)>e){
- if (n!=0){
- for (int p = 1; p <= n; p++) {
- nf *= p;
- }
- }else nf=1;
- s*=(pow(-1,n)*pow(x,n))/nf;
- sum+=s;
- n++;
- }
- nf=0;
- printf("%10.2f | %8.2f | %3d | %8.2f | \n",x,sum,n,F);
- }
- cout<<"------------------------------------------\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement