.


:




:

































 

 

 

 


. ,




Ͳ

1. . , , - . C++ :

: "",..., "Z", "",..., "z";

0, 1,..., 9;

: " ' () [ ] { } < >.,;:?! ~ * * = / \ | # % $ & ~ ^ @ _.

, ( , , ). - : , , .

. ('), ', , , , . , , . .

1. C++ . , MyName myname '.

. . 쳭 . C++:

asm double mutable switch

auto else new template

bool enum operator this

break explicit private throw

case extern protected try

catch float public typedef

char for register typename

class friend return union

const goto short unsigned

continue if signed virtual

default inline sizeof void

delete int static volatile

do long struct while

3. . , . , . C++ #. .

#include , .

, #include, (header-, , ). , () .

C++ . , :

#include < .>

:

#include " \ ."

INCLUDE C++. , <...>,

# include <math.h>

INCLUDE, "...". , MyBib.h stud d:, : #include "d:\stud\MyBib.h".

2. ISO/ANSI #include , #include <math>. , ++-, , , #include <cstdio>. .

#define . -, ( ). , #define N 25, N 25. -, ( ) , , :

# define D(a, b, ) ((b) * (b) - 4 * (a) ()).

d=b*b4*a*c d = D(a, b,c).

#undef #define. ,

# define D(a,b,c) ((b) * (b) - 4 * (a) * ())

#undef D

# define D(a,b,c) ((a) * (b) * (c))

17.

4. . C++ , , . , ,

main(void)

{

return 0;

}

main() . void , , '. . . ";" ( ). return. ҳ ( ) { }.

, : ! C++!

#include <iostream.h> // C++

 

using namespace std;

int main()

{

cout << " Hello! Welcome to C++!";

return 0;

}

. . , . : // : /* */. , . : -, .

#include <iostream.h> ' iostream.h. , - .

' main(). int , main() .

cout << "! C++!".

return main(). return () ( - 0).

3. main() :

void main()

{

;

}

main() void. , return .

5. . C++ :

//

# include < >

void main()

{

< >;

}

4. , < > , . , , . .

. C++ :

//

# include < 1>

# include < N>

< >

< >,

< >;

< >;

< > main ( )

{

< >;

< >;

<>;

}

. , , , , , .

6. . - 䳭 ' ', .

( ) : ('), , . .

' ', . , , (), 䳭 ' .

() 񳺿 , (, const). :

const < 1> = < 1>;

:

const <> < 2> = < 2>;

2 . . ϳ .

1.

const vik = 20, rist = 176;

const float g =2.78;

g float 2,78.

5. C++ : π _в, π/2 _в_2, π /4 _в_4, 1/π _1_в, 1 / M_1_SQRTPI . ֳ , math.h.

, , . :

< 1> < 1>;

< N> < N>;

. , :

int a, c; float b, d, z; char w;.

. .

, float b, d = 2.5, = 4; char w = t;.

, :

< > < 1> = < 1>,...,

< N> = < N>, < >;

1. ?

2. ? ?

3. ?

4. ? ?

5. ?

6. .

7. ?

8. ?

9. ?

10. ?

:

) ;

) ;

) ;

) .

 

 

1. . , ' , . , , ', .

1. '.

, ' , sizeof (<Ha >). , cout <<sizeof(short int) 2. , short int ' ' 2 .

. 1, 2 , ', , .

() .

2. ֳ . ֳ . 1.


1.

, ij
int 2 4 -32768... 32767 -2147483648... 2147483647
short int   -32768... 32767
unsigned short int 2 4 0... 65535 0... 4294967295
long int   -2147483648... 2147483647
unsigned long int   0... 4294967295

1. :

int , ; short int z;

, , z '.

, , :

x = 157; = -68; z = 15;.

', 157, -68, z 15.

ϳ . , = 2003 ' 2003 ( 157 ).

2. :

const int a = 145:

const long int b = 365978.

b .

3.ij . ij . 2.

2. ij

, ij
float   +3.41&38...3,41038; 0
double   1,7-1 308...1,710308; 0
long double   1,1810-4932...+18101932; 0

2. .

3.

float h, pi = 3.1415926; double v = 365.976;

const float w = -12, h = 23.4;

(h, pi) float v double, w = -12; h = 23.4 float.

ij , -2.3, 5.0041, ( ), , -0.2+2 ( -:0), 3.27-3 ( 0,00327).

10 , = ∙ 10

"+" , "" '.

4. (char). , ' ASCII. , , 8-, 10- 16- , ASCII.

4. , ml, m2, m3 m4 :

char m1 = 'A';m2 = 0101, m3 = 65, m4 = 0x41.

65 '', 101 , 41 . (101, 41) "0" "0" .

5. ASCII- , '':

char c= ''; int n = ;.

65.

5. (bool). : false () true (). , bool b = true. 1 ' '. C++ int : false, true.

, bool. , , ' .

6. void. void , . .

. ,

typedef < > < >;

6. kilkist :

typedef unsigned short int kilkist;

(kill, kil2) : kilkist kill, kil2;.

1. ?

2. ?

3. ?

4. ?

5. ?

6. ?

7. 12.51, 12.5-2, 0.1254, 125-3?

8. 8.5-1, 92.52, -0.45, -4-2?

9. ?

10. ASCII- ?

11. ?

12. ?

1. : ) ; ) ; ) . .

2. n, ' . ?

3. Vaga, typedef unsigned long int Vaga?

4. balans -32 000 32 000.

 

 

Ϊ

1. . , ' .

1 ( ). = 3, b = 4. .

// 1

#include <iostream>

#include <math.h>

using namespace std;

void main()

{

int a = 3, b = 4, p=0; //

double c, s;

= sqrt((double)(a * + b * b)); //

= + b + c; //

s = * b / 2; //

cout << " = " << << "\"; //

cout << "s = " << s << "\n"; //

cout << "Vykonav st. Ivaniv A."

}

"*" , "/" . sqrt() . math.h, ' . ϳ

=12

s = 6

Vykonav st. Ivaniv A.

2. . . :

< > = <>

< 1> = < 2> =... = < N> = <>

ij . . , . , , , , ' .

:

= 8-2; = d = + 4; = d /5 + ;

' . , ( ). , C++ () .

, .

.

1. , int float ( ) b int:

//

#include <iostream.h>

void main() {

int b, a; float c;

cout << " \n":

cin >> ; //

cout << " \n":

cin >> ; //

b = * :

cout <<" = " << << "\n";

cout <<" = " << "\n";

cout <<"b = "; cout << b << "\n";

}

n >>.

: a = 2, = 3.8,

= 2

= 3.8

b = 7

( ∙ a = 3.8 2 = 7.6). b , 7,6 b 7. ³ ( ). b float, b = 7,6.

. b = (int) c * ;

(3), ( ∙ a = 3 2 = 6). = 2, = 3.8, b = 6.

: b = (int) (c * );

( ∙ a = 3.8 2 = 7,6), (b = 7). = 2, = 3.8, b = 7.

, , . . : double, float, long, int, short. .

1. 1 , ' 1 "" :

) ;

) ;

) .

2. ' 1 "" . .

 


 

Ͳ

1. C++ . 3.

3.

  +,
  *, /, % , ,
  +, ,
  = =,!=, <, <=, >, >= ()

 

. = = ,!= , <= , >= .

( 1 ). .

1.

2*-5 + 4 = -6; 12/4-2 = 1;

2*(-5+ 4) =-2; 12/(4-2) = 6;

7 % 3 = 1; 7 % 3 * -5 = -5.

2. = 3, = 5. = = . false (), , != true (), > , <= ( 2) false true.

2. (++) ( ). . ++ () () , . :

++<> <>++

ij . . ++, ++ = + 1. () . .

3.

= 2;

b = 3 * ++;

: = 3, b = 3 ∙ 3 = 9. : , .

4. = 5; d = (++) + 4;

( d) = 5, . d = + 4 = 5 + 4 = 9, = + 1 = 5 + 1 = 6 ( ). "+" , .

:

<> <>

. = 1.

5. = 4; = 15/ ;

: = 3, = 15/3 = 5. , .

6. ϳ

f = 20;

g = (f ) 10;

f, g 19 10 .

3. , . , , , : +=, =, *=, /, %=. , , :

<> < >= <>

, "=" ( ). ,

= + 10 +=10

. , += 10. b = 4 * b b *= 4.

4. . C++ math.h. , , '

#include <math.h>;.

math.h . 4. .

4.

 
abs(x) |x|   fabs(x) |x|
cos(x) cos   acos(x) arcosx
sin(x) sin x   asin(x) arcsinx
tan(x) tg x   atan(x) arctgx
log(x) ln x   ceil(x)
pow(x.y)  
sqrt(x)   floor(x)
     
exp(x) ex   fmod(x, y)
pow10(x) 10*  
Iog10(x) lg*      

7.

int - -2, 1, = 3;

float pi = 3.1415926, m = 16, kut, ;

1 = abs(x); a=pow10(a);

kut = cos(2 * pi);

k = pow(m, 1./4);

m = sqrt(m);

x1, a, kut, k, m :

1 = abs(-2) = I -2 I = 2; a = pow10(3) = 103= 1000;

kut = cos(2* 3.1415926) = 1; k = pow(16, 1./4) = 161/4=2;

m = sqrt(16)= =4.

8. b, b1, b2 double b = 7.6.

b1 = ceil(b);

b2 = floor(b);

b1 8, b2 7.

. , ctgx = 1 / tgx, lg b = ln(a) / ln(b) .

, , :

1) , ;

2) , , ;

3) .

. . , . ʳ .

(, , ) . . . "" , , . .

9. ,

= = 2.

#include <iostream.h> //

#include <math.h>

void main()

{

const float pi = 3.1415926;

float x = 2, y;

= pow(x * x + 7.2, 1. / 5) - fabs(x - 5) + sin(pi * x / 3);

cout <<"\n = " << << "\n";

}

: = -0.512748.

1. , "" . . .

2. C++ :

) ;

) ;

) ;

) .

 

 





:


: 2016-03-27; !; : 1090 |


:

:

,
==> ...

1869 - | 1788 -


© 2015-2024 lektsii.org - -

: 0.169 .