.


:




:

































 

 

 

 


.




C=A U B

C=A ^ B

C= A-B

C=(A-B)U(B-A) - .

 

#include<iostream>

/////////////////////////////////

void create_set(int* x,int n)

{

int i,m;

for(i=0;i<n;i++)

x[i]=0;

char ch=y;

while (ch==y || ch==Y)

{

cout<<enter element of set m=;

cin>>m;

x[m]=1;

cout<< continue enter element? y/n ch=;

cin>>ch;

}

}

////////////////////////////////

void show_set(int* x,int n)

{

int i;

cout<<{ ;

for(i=0;i<n-1;i++)

if (x[i]) cout<<i<<, ;

cout<<x[n-1]<< } <<endl;

}

////////////////////////////////////

void union(int* x,int* y,int* z, int n)

{

int i;

for(i=0;i<n-1;i++)

z[i]=x[i]||y[i];

}

////////////////////////////////

void intersection(int* x,int* y,int* z, int n)

{

int i;

for(i=0;i<n;i++)

z[i]=x[i]&&y[i];

}

////////////////////////////////

void substruction(int* x,int* y,int* z,int n)

{

int i;

for(i=0;i<n;i++)

z[i]=x[i] &&!y[i];

}

////////////////////////////////

void complement(int* x,int* y, int n)

{

int i;

for(i=0;i<n;i++)

y[i]=!x[i];

}

 

 

////////////////////////////////

void main()

{

int I,n;

cout<< ALGEBRA OF SETS<<endl;

cout<<enter size universal set n=;

cin>>n;

int* a=new int[n];

int* b =new int[n];

int* c=new int[n];

cout<<enter elements of set a:<<endl;

create_set(a,n);

cout<< elements of set a:<<endl;

show_set(a,n);

cout<<enter elements of set b:<<endl;

create_set(b,n);

cout<< elements of set b:<<endl;

show_set(b,n);

union(a,b,c,n);

cout<< elements of set c=aUb:<<endl;

show_set(c,n);

 

intersection(a,b,c,n);

cout<< elements of set c=a*b:<<endl;

show_set(c,n);

substruction(a,b,c,n);

cout<< elements of set c=a-b:<<endl;

show_set(c,n);

complement(a,c,n);

cout<< elements of set c=!a:<<endl;

show_set(c,n);

 

}

 

 

 

.

 

t 1, , tm e. m, a, b, e t [1: m ]. y [1: m ], . :

- , F (x, t), x t;

- : a, b, e, F (x, t) t.

I. ( ):

)

;

, .

 

II. .

.

y (x):

;

j (z):

;

 

III.

  a b e M t 1 t 2 t 3 t 4 t 5 t 6
)     0,1   -3,7 1,8 7,2 - - -

 

 

// integral_function

//arb2013_integral_function

#include<iostream.h>

#include<fstream.h>

#include<math.h>

#include<iomanip.h>

#include<string.h>

const int lengthColumn=20;

const int Indent=7;

const int lengthTable=43;

//////////////////////////

double Fi(double x)

{

return cos(x)*cos(x);

}

///////////////////////////////

double Psi(double x)

{

return (1-x*x)/(1+x*x);

}

/////////////////////////

double F(double x,double t)

{

return Psi(x)*Fi(x+ t/(1+x*x));

}

///////////////////////////////////////

void create(ifstream &f, double x[], int n)

{

int i;

for(i=0;i<n;i++) f>>x[i];

}

/////////////////////////////////////////

void show(ofstream &f, double x[], int n)

{

int i;

for(i=0;i<n;i++)

f<<x[i]<<' '; f<<endl;

}

/////////////////////////////////////////

double Integral(double a, double b, double e, double t)

{

double h,J1,J2;

int i,n;

n=1; h=(b-a)/n;

J2=h*F(a+h/2, t);

do

{

J1=J2;

n=n*2;

h=(b-a)/n;

J2=0;

for (i=0;i<=n-1;i++)

J2=J2+F(a+(2*i+1)*h/2,t);

J2=J2*h;

}while (fabs(J2-J1)>e);

return J2;

}

//////////////////////////////////////

void star(ofstream &f, int n, int m)

{

f.width(n);

int i;

for(i=0;i<m;i++)

f<<'*';

f<<endl;

}

/////////////////////////////////////

void star1(ofstream &f, int n, int m)

{

f.width(n); f<<'*';

int i;

for(i=0;i<m;i++)

{

f.width(lengthColumn+1);

f<<'*';

}

f<<endl;

}

//////////////////////////////////////

void table(ofstream &f,double* x,double* y,int m, char a[2][15])

{

int i;

f<<endl;

star(f,Indent+1,lengthTable);

star1(f,Indent+1,2);

f.width(Indent+1);

f<<'*';

for(i=0;i<2;i++)

{

f.width(10);

f<<a[i];

f.width(11);

f<<'*';

}

f<<endl;

star1(f,Indent+1,2);

star(f,Indent+1,lengthTable);

for(i=0;i<m;i++)

{

f.width(Indent+1);

f<<'*';

f.width(lengthColumn-5);

f<<x[i];

f.width(6);

f<<'*';

f.width(lengthColumn-5);

f<<y[i];

f.width(6);

f<<'*';

f<<endl;

star1(f,Indent+1,2);

star(f,Indent+1,lengthTable);

}

}

 

 

/////////////////////////////

void main()

{

ifstream in("arb.txt");

ofstream out("integral.txt");

double a,b,eps;

int m,i;

char name_task[80];

char name_x_y[2][15];

in.getline(name_task,80);

 

for(i=0;i<2;i++)

in>>name_x_y[i];

out<<name_task<<endl;

 

for(i=0;i<2;i++)

out<<name_x_y[i]<<' ';

out<<endl;

 

in>>a>>b>>eps>>m;

out<<"a= "<<a<<endl;

out<<"b= "<<b<<endl;

out<<"eps= "<<eps<<endl;

out<<"m= "<<m<<endl;

 

double* t, *y;

t=new double[m];

y=new double[m];

 

create(in, t,m);

out<<"arguments: "<<endl;

show(out,t,m);

 

 

for(i=0;i<m;i++)

y[i]=Integral(a,b,eps,t[i]);

 

out<<"value of integeral"<<endl;

show(out,y,m);

out<<endl;

 

out<<setw(15+strlen(name_task))<<name_task<<endl;

table(out,t,y,m,name_x_y);

 

in.close();

out.close();

delete []t;

delete []y;

}

////////////////////////////////////////

 

arb.txt

 

Calculate integral.

x[i] y[i]

 

0 1 0.001 3 -3.7 1.8 7.2

//////////////////////////////////////

integeral.txt

 

Calculate integral.

x[i] y[i]

a= 0

b= 1

eps= 0.001

m= 3

arguments:

-3.7 1.8 7.2

value of integeral

0.406703 0.0658141 0.335945

 

 

Calculate integral.

 

*******************************************

* * *

* x[i] * y[i] *

* * *

*******************************************

* -3.7 * 0.406703 *

* * *

*******************************************

* 1.8 * 0.0658141 *

* * *

*******************************************

* 7.2 * 0.335945 *

* * *

*******************************************

 





:


: 2016-12-06; !; : 392 |


:

:

.
==> ...

1541 - | 1379 -


© 2015-2024 lektsii.org - -

: 0.036 .