include QtCore QCoreApplication include iostream include math using na

 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
#include <QtCore/QCoreApplication>
#include<iostream>
#include<math.h>
using namespace std;
float rasch (float x)
{
return (1+x*x)/(x*x*x+sqrt(1+x));
}
int main(int argc, char *argv[])
{
float a=0,b=0,n=100;
float h=1;
float arr[100];
float sum=0;
int Switch=0;
cin>>a>>b;
h=float((b-a)/n);
cout<<"Задайте вариант решения";
cin>>Switch;
switch(Switch){
case 1:
arr[0]=rasch(a)/2;
cout<<"arr[0]\t"<<h<<"\n";
for(int i=1; i<100;i++)
{
arr[i]=rasch(a+h*i);
}
arr[100]=rasch(b)/2;
cout<<"arr[100]\t"<<arr[100]<<"\n";
for(int i=0;i<101;i++){
sum+=arr[i];
cout<<arr[i]<<"\n";
}
sum=sum*h;
break;
case 2:
arr[0]=rasch(a);
arr[1]=rasch(b);
for(int i=2;i<100;i++){
arr[i]=rasch(a+i*h)*4;
sum+=arr[i];}
for(int i=2;i<99;i=i+2){
arr[i]=rasch(a+i*h)*2;
sum+=arr[i];
}
sum+=arr[0];
sum+=arr[1];
sum=sum*(h/3);
break;
default: cout<<"Throw IOException";
}
cout<<"OLOLORSULT\t"<<sum<<"\n";
}