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