1)
#include
using namespace std;
int main() {
double x,xn,s;
int n=20,z=1;
cout << "x = ";<br> cin >> x;
xn=x;
s=x;
for (int i=1; i<=n; i++) {<br> xn=xn*x*x;
z=-z;
s=s+z*(i+1)*xn/(2*i+1);
}
cout << "s = " << s;<br> return 0;
}
2)
#include
using namespace std;
int main() {
double x,xn,s;
int n=20,i=0,z=1;
cout << "x = ";<br> cin >> x;
xn=x;
s=x; while (i i++;
xn=xn*x*x;
z=-z;
s=s+z*(i+1)*xn/(2*i+1);
}
cout << "s = " << s;<br> return 0;
}
3)
#include
using namespace std;
int main() {
double x,xn,s;
int n=20,i=0,z=1;
cout << "x = ";<br> cin >> x;
xn=x;
s=x;
do {
i++;
xn=xn*x*x;
z=-z;
s=s+z*(i+1)*xn/(2*i+1);
}
while (i cout << "s = " << s;<br> return 0;
}
Пример:
x = 1.5
s = 5.8792e+06