.


:




:

































 

 

 

 


2.




 

. ++ - .

++ , , , . .

 

3.

++

( )

4. .

(linking). ++ , ( cpp ), , , . - ++ . (linker) , . , .

 

 

5.

 

, .

 

6.

 

, , .

 

 

bool true 1; false 0 1

char

signed -128 127 1

unsigned 0 255 1

Int

signed mod 232-1 4 a

unsigned 0 4 294 967 295 4 a

Double 3.4e-308-1.7e+308 8

 

 

2

Bool a,y,z

True-

False-

&&- *, ^.& -and

||-v-or

!- ⌐X-not

X Y X&Y XVY ⌐X
         
         
         
         

 

⌐XvY= ⌐X&⌐Y ⌐ X&Y= ⌐Xv ⌐Y

X Y XVY ⌐XVY ⌐X ⌐Y ⌐X&⌐Y
             
             
             
             

 

X&(Y v Z)=X&Y v X&Z

X v (Y&Z) =(X v Y) & (X v Z)

X v ⌐X =1

X & ⌐X =0

 

X Y

X Y XàY
     
     
     
     

X ^ Y

X v Y

 

 

D=D1^D1^D2^D3^D4

(X,Y) D →((X,Y) D1)& ((X,Y) D2)& ((X,Y) D3)& ((X,Y) D4)

(X,Y) D →(Y>=X-1)&& (Y<=X+1)& & (Y<= -X+1)&& (Y >= -X-1)

 

 

D=D1vD1vD2vD3vD4

 

 

(X,Y) D→(Y>=X-1) || (Y<=X+1)|| (Y<= -X+1)|| (Y >= -X-1)

A X\Y=X ^ Y

X\Y c X ^ Y

X ^ YcX\Y

:

1) p X\Y=(p X)&(p Y )= p X ^ Y

2) p X ^ Y=(p X)&(p Y )= p X\Y

D1\D2

(X,Y) D1\D2 =(X,Y) D1^ D2

((X,Y) D1)&&((X,Y) D2)↔ ((X,Y) D1)&&!((X,Y) D2)

 

 

3

 

If (B) C1; else C2;

, C1;

, C2;

 

If (B) C1;

if (B) {c1;c2;}

else c3;

*{c1;c2;}-

1) max

x, y

max=max{x, y}

 

if (x<y) max=y;

else max=x;

max=max{x, y, z}

1)

if (x<y)

if (y<z) max=z;

else max=y;

else if (x<z) max=z;

else max=x;

 

2)

max=x;

if (max<y) max=y;

if (max<z) max=z;

 

 

3)

 

 

if (1) {if (2) 1;}

else 2;

4)

if (1)

if (2) 1;

else 2;

5)

if (1)

{

1;

if (2) {2;3;}

else {4;5;}

6;

}

else

{

if (3)

{

if (4) {3;4;}

}

else 9;

10;

}

 

 

6) ax2+bx+c=0

 

# include <iostream.h>

# include <math.h>

void main()

{

int a,b, c;

double x, d, x1, x2;

cout<<Enter a, b, c;

cin>>a, b, c;

if (a==0)

{

if (b==0)

{

if (c==0) cout<<x- ;

else cout<< ;

}

else {x= -c/b;}

}

else

{

D=b*b-4*a*c;

if (D>=0)

{

x1=(-b+ sqrt(D))/(2*a);

x2= (-b- sqrt(D))/(2*a);

}

else cout<< ;

}

cout<<endl;

}

b2=paw(b,2)

void main()

{

int i;

i=5;

{

int i;

i=10;

cout<<i; // 10

}

cout<<i; // 5

}

 

4

0,1,2,3,4,5,6,7,8,9

904=9*102+0*10+4*100

0,1

1012=1*22+0*2+1*20=510

0,1,2

1013=1*32+0*3+1*30=1010

0,1,2,3,4,5,6,7,8,9,A, B, C, D

ABBA16=10*163+11*162+11*16+10*160=40960+2816+176+10=4396210

904,90410=1110001000,1112

904/2=452 0

452/2=226 0

226/2=113 0

113/2=56 1

56/2=28 0

28/2=14 0

14/2=7 0

7/2=3 1

3/2=1 1

0,904*2= 1,808

0,808*2= 1,616

0,616*2= 1,232

0,232*2= 0,464

, , .

0110111011100011=123232034

= 673438

=6316

10 16 2

0 0 0000

1 1 0001

2 2 0010

9 9 1001

10 1010

11 B 1011

12 C 1100

13 D 1101

14 E 1110

15 F 1111

 

10010=11001002=12104=1448=6416

int x =100

=4

1 =8 4 =32

0→1

1→0

1,

0,25*1010-

Double 4

1234 -

int x=100; double y=2.5;

y-y+x- double

 

1)

 

 

While (B) C;

 

 

 

While (B)

{

C1;C2;C3;

}

 

 

Do C while (B)

 

 

1

while

y=1+2+3+..+n

y=∑in=1i

 

# include <iostream.h>

void main()

{ int i,y, n;

cout<<Enter n=;

cin>>n;

y=0;

i=1;

while (i<=n) { y=y+i;

i++;

}

cout<<y=<<y<<endl;

}

 

do while

y=1+2+3+..+n

 

# include <iostream.h>

void main()

{ int i,y, n;

cout<<Enter n=;

cin>>n;

y=0;

i=1;

do { y=y+i;

i++;

}

while (i<=n);

cout<<y=<<y<<endl;

}

 

 

2

y=1/1!+1/2!+1/3!+1/n!

y=y+1/f - double

 

 

# include <iostream.h>

void main()

{

 

int i,f, n;

double y;

cout<<Enter n=;

cin>>n;

y=0;

i=1;

f=1;

while (i<=n)

{f=f*i;

y=y+(double)1/f;

i++;

}

cout<<y=<<y<<endl;

}

 

3

y=sin(x)

sin (x) =x -x3/3!+x5/5!-x7/7!+

sin(x) = ∑0 (-1)i x2i+1 / (2i+1)!

 

1

 

step=x

znak=1

fact=1

y=y+ step*znak/fact

 

# include <iostream.h>

# include <math.h>

void main()

{

int i, n, fact, znak;

double y,x,step;

cout<<enter x=;

cin>>x;

cout<<enter n=;

cin>>n;

y=x;

znak=1;

step=x;

factorial=1;

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

{

znak=-znak;

step=step*x*x;

factorial=factorial*2*i*(2*i+1);

y=y+znak*stepen/fact;

}

cout<<y=<<y;

cout<<sin(x)=<<sin(x);

}

 

2 ( )

y= x-x3/3!+x5/5!-x7/7!+

y=∑0 (-1)i x2i+1 / (2i+1)!= ∑0ti

ti=ti-1*p

p= ti/ ti-1= ((-1)i x2i+1 / (2i+1)!)/ ((-1)i-1 x2i-1 / (2i-1)!)= -x2/2*i*(2*i+1)

 

# include <iostream.h>

void main()

{

double y, x, t;

int i, n;

cout << enter x=;

cin >> x;

cout << enter n=;

cin >> n;

y=x;

t=x;

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

{

t= -t*x*x/((2*i+1)*2*i)

y=y+t;

}

cout << y= << y;

}

 

while-

 

# include <iostream.h>

# include <math.h>

void main()

{

const double eps=0.001;

double y, x, t;

cout << enter x=;

cin >> x;

y=0;

t=x;

int i=1;

while (fabs(t)>eps)

{

y = y+t;

t = -t*x*x/((2*i+1)*2*i);

i++;

}

Cout << y= << y;

}

 

2) for

 

for (int i=1; fabs(t)>eps; i++)

{

t= -t*x*x/((2*i-1)*2*i)

y=y+t;

}

 

 

4

 

Cos(x)=∑i (-1)i x2i / 2i!

p = -x2 / ((2*i+1)*2*i)

 

# include <iostream.h>

void main()

{double y, x, t; int n;

int n;

cout<<enter x=;

cin>>x;

cout<<enter n=;

cin>>n;

y=x;

t=x;

for (int i=1;i<=n;i++)

{

t= -t*x*x/((2*i-1)*2*i)

y=y+t;

}

cout<<y=<<y;

}

5





:


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


:

:

, .
==> ...

1454 - | 1368 -


© 2015-2024 lektsii.org - -

: 0.331 .