include STDIO include MATH include CONIO include windows include ioman

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <STDIO.h>
#include <MATH.h>
#include <CONIO.h>
#include <windows.h>
#include <iomanip>
#include <iostream>
#include <stdlib.h>
#define n 100
using namespace std;
int main()
{
float a, b, h, x, s = 0, s1 = 0, s2 = 0, f[n],sn = 0,sn1;
setlocale(LC_ALL,"Russian");
do
{
cout<<"Введите a и b \n";
cin>>a>>b;
}
while (a>b);
h=(b-a)/n;
f[1]=pow(a, 2) * log10(a) / pow((1+a), 2);
f[100]=pow(b, 2) * log10(b) / pow((1+b), 2);
for(int i=1; i<n; i++)
{
x=(a+i*h);
f[i]=pow(x, 2) * log10(x) / pow((1+x), 2);
sn+=f[i];
}
s=(h/2)*(f[1]+f[100]+2*sn);
cout<<setprecision(3)<<"\nZnach s=\t"<<s << "\n";
//Формула Симсона
for(int i=1; i<n-1; i++)
{
x=(a+i*h);
f[i]=pow(x, 2) * log10(x) / pow((1+x), 2);
if (i%2) s1+=f[i]; else s2+=f[i];
}
sn1=(h/3)*(f[1]+(4*s1)+(2*s2)+f[100]);
cout<<setprecision(5)<<"Ответ 2 =\t"<<sn1;
getch ();
return 0;
}