.


:




:

































 

 

 

 


1. .

2. .

3. ().

4. ().

5. ().

6. .

7. ().

8. .

.

, . 8 , 2 , 2 , 15/, 1 .

:

()

= 2

= 2

= =_, _ _ /3

= 15 /

=_ _ / 1

= 8 /

 

()

1 = 1000 /

2 = 1000 /

3 = 106 3 / 3 3 3

4 = 60 /

 

 

= ×/1 [2=××/]

= ××4 [3/=2×/×/]

=×/2×3 [/= /3×3//(/) × 3 /3]

=× [/= / × / ]

=× [/=/×/]

 

, , . .

 

 

 

 

, .

, , .

++

++ 80- AT&T Bell Laboratories . ++ , 1972 .

++ . -, , , , .

-, .

++ , Java, , ++.

++ , , , . , , .

1983 (ANSI) . 1989 ANSI, (ISO). ++ ANSI ( 1995).

++ International Standard for Information Systems Programming Language C++ (ISO/IEC JTC1/SC22/WG21) []. ++, .

 

2.1.

++ 52 ( ) :

A B C D E F G H I J K L M N O P Q R S T U V W Z Y Z

a b c d e f g h i j k l m n o p q r s t u v w z y z

10 :

0 1 2 3 4 5 6 7 8 9

30 :

 

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

 

2.2.

.

:

- ;

- ;

- ;

- .

 

 

2.2.1.

/++ , .

++ .1

1

auto long
bool new
break , operator
case overload
char private
class protected
const public
continue register
default return
delete short
do signed
double sizeof
else static
enum struct
extern switch
float this
for typedef
friend union
goto virtual
if volatile
inline void
int while

2.2.2.

, . , (, , , ).

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

, .

, . , , . , , , .

. 2 /++, .

2

/
min max
           
  Bool     false (0) true (1)
  signed char ( char)     -128  
  unsigned char        
  int[1]     -32768  
  unsigned int (unsigned)        
  short int (short)     -32768  
  unsigned short int (unsigned short)        
  long int (long)     -2147483648  
  unsigned long int (unsigned long)        
  Float     3,4 -38 3,4 +38
  Double     1,7 -308 1,7 +308
  long double     3,4 -4932 3,4 +4932
         
  void[2]    

. () .

:

u1[=c1] [,u2[=c2], , uN[=cN] ];

, , , :

[ ]

[ ] ;

, ;

, ;

u1 uN ;

, ;

1 N ,

;

= ;

; .

. (,). (;).

() 256 , [3] ( ).

, . (Abc abc )! , , .

.

, . , .

(=).

, .

bool 1 , , , 0 (false, ) (true, ). BOOL , TRUE FALSE. , unsigned short, 1 0, . ++ bool .

, . ( int, long, short), , , . , . ( ) . , . , , unsigned. ( signed, , , , ).

char , ANCII. , , , . . char .

float. , , 4 : 1 , 8 , 23 . , 7-8 .

, , double ( , ) long double. double 8 : 1 , , ). 16-17 , 20 . (pointer) , . void . , , . , void. int A2, igr; double s, s1; float summa; long int sh; short int n, N; unsigned short it, i, j, k; long int, short int (. . 2) int . : long sh; short n, N; : int ss, sr, sob1; (), . . .:char per='\n';int pc=265, i=0;float x, y, z=15.e-3;! !

2.2.3.

, . , : , , .

, (): 'e', '@', '>'.

. " " . , , . , 007. . ,

'\007', '\07', '\7'

. .

, :

" ! ".

, . ", ', \, \", \', \\.

:

, " \ ",

:

", \" \\ \"".

(), '\0'. - '\0' , . , 'T' "T" ( ) , , , , \0. .

+(-) . :

- ;

- ;

- .

, , , : 123; 2384.

( 0 7), , : 034; 047.

0 0 0 9 , , , D, E, F, (a, b, c, d, e, f), 10 15 . : 012, -017, 0FF, 0xfa62.

. . -32768 +32767, 0 65535.

( ). L (l) . :

1000242L 047777777l +12345678L -0XA761263l

( )

[m].[n][Ep] ([m].[n][ep]),

m ( ;

n ( );

p ( );

E () ();

[ ] .

. : 3.14159 -255..79 -1.5612 2.87-3 10.6.312 6-2

.

. , . 1038 6-7 . ( ). . , F (f).

, .

const, , , , .

++ 1 , , 0 255 (. . 3). , , : , , escape-. escape - Epson, , . , 27 (01), "Escape" ASCII.

Escape- , .

3

\\
\'
\"
\?
\a
\b 1
\f
\n
\r
\t
\v ()

 

:

const double Pi=3.1415;

3.1415. , , () Pi.

2.2.4.

, (), . , .

, , . , #include. ( , ).

[] ([]);

() ;

.

,

int;

,

,

.

.

;

() ;

[ ] .

 

.

, , , .

, () .

, . , .

( ), , :

(1[,a2, , an])

;

1 n ;

, ;

() ;

[ ] .

. (. . 4). math.h.

4

xy pow(x,y)
ex exp(x)
ln x log(x)
log x log10(x)
sqrt(x)
fabs(x)
sin x sin(x)
os x os(x)
tg(x) tan(x)
arcsin x asin(x)
arccos x acos(x)
arctg x atan(x)
arctg y/x atan2(x,y) y/

 

, ( ).

.

2.3.

, ( ) , . , , , .

/++ , .

/++ . , , , , . . . , , , , .

= ; = L;

;

=

A(L) () ;

; .

, , (). , . . , . . , . , . . , x = y = z x = (y = z), x + y + z (x + y) + z, .

. 5.

 

5

         
  ::   =>
  [ ]   =>
  ()   =>
  .   =>
  ->
  ++   <=
  --   <=
  ++   <=
  --   <=
  sizeof sizeof()   <=
  ()    
  ~   <=
  !   <=
  -   <=
  +   <=
  &   <=
  *   <=
  new new[]   <=
  delete delete[]   <=
  casting    
  *   =>
  /   =>
  %   =>
  +   =>
  -   =>
  >>   =>
  <<   =>
  <   =>
  <=   =>
  >   =>
  >=   =>
  ==   =>
  !=   =>
  &   =>
  ^   =>
  |   =>
  &&   =>
  ||   =>
  ?:   <=
  =   <=
  *=   <=
  /=   <=
  %=   <=
  +=   <=
  -=   <=
  <<=   <=
  >>=   <=
  &=   <=
  ^=   <=  
  |=   <=
  throw   <=
  ,   =>

.

.

= ;

( );

(. . 5);

;

; .

= ;

, a*=b; a=a*b; a-=b; a=a-b;

2.3.1.

: (-), (++), (--), (+), (-), (*), (/), (%). , (), , 1 1. unsigned, 2n, n , int.

, ++ .

/ :

: INC N

: DEC N

N , .

. . .

:

x = y++; //

index = --current;//

count++; //

// , ++count;

abc--; // , --abc;

, . current , index.

(char, short, int, long) . , 6%2 0, 5%2 1, 7%4 3 .. .

/++ (/). , , .

! , . , , :

volume = 4/3*Pi*r*r*r;

, . 4/3, , 1. 1.0. , , 1.0 1.333...

, , , (short, long . .), . . . , .

. , " " "". , . :

har, short

Int, long

Float

Double

Long double

, , . . , , , .

_() (_)

, ( ). , ( ) . -, . :

int i = 1;

float f = float (i+1);

unsigned long ul = (unsigned long)i;

unsigned long (i) .

2.4.

, . ++ :

-, , ;

;

, .

, , :

{ 1; 2; }

: , , .

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

2.4.1. /++

/++ -. /++ -, stdi.h, include.

++ - -.

-.

scanf()

scanf():

scanf(" ", 1[, 2,,n]);

scanf ;

" " -

(),

;

1,,n - ,

;

,, - ;

[ ]

; - .

scanf() ( ) ( ) , . , . (-) . scanf() , . . , 0.

, :

-;

, -;

.

- ,

(\t) (\n). , .

, - , (%). , .

, , . . , , . , , , .

:

% [*] [] [F |[4] N] [h | l | L] _

(%).

. 6 .

6

* . , . , , , , , (type_char), .
. . , -.
F | N . : N near pointer F far pointer
h | l | L . , : h = short int l =long int, type_char l=double, type_char L=long double ( )
_ ()

. 7.

 

7

d (int). h, (short int). h, (long)
D (long)
E,e . l, double. L, long double.
f . l, double.
(int)
(long)
i , (int)
I , (long)
u (int)
U (unsigned long)
(int)
(long)
s (char arg[])
c

, , . . . (^), : , .

,

%[abcd] - a, b, c, d.

%[^abcd] - , a, b, c, d.

, .

,

%[0-9] .

%[0-9A-Za-z] .

, .

- (-) . , , , . .

. ( ) . . (). , , . (&). , :

&,

& .

,

.

, a, x2, summa &a, &x2, &summa.

. .

scanf() :

 

int i, res;

float fp;

char c, s[81];

res=scanf("%d%f%c%s",&i, &f, &c, s);

printf("\n\n %d \n",res);

printf(":\n %d %f %c %s\n", i, f, c, s);

 

:

1234 1234.5678 F string

:

4

:

1234 1234.5678 F string

printf().

printf():

printf(" ", [1,,n]);

printf ;

" "

(),

;

1,,n ,

(

);

,, - ;

[ ]

; - .

printf() stdout ( ). , , . , , . , , , . , EOF.

printf() , , . , :

, ;

, ( ), .

:

%[] [][.][F | N | h | l | L]

(%), , . 8.

8

. , , , ,
. ( )
. ;
F | N | h | l | L .

() . . 9.

9

- .
  .
+ .
, .
# 0 .

: (+) (' '), .

. :

;

, (*).

, ( ) , . , . , . . 10

10

N N . N , (, (-), ).
0n , , n . n , .
* , .

printf() . , . , :

, ;

, (*).

, ( ) . , , , .

. . 11. , , , , .

11

d .
i .
o .
u .
x (, 16- a,b.c,d,e,f).
X (, 16- A,B.C,D,E,F).
f [-]dddd.dddd
e [-]d.dddd [-]d.dddde[+/-]ddd


<== | ==>
- (3- ) | ,
:


: 2016-09-06; !; : 465 |


:

:

, , 1:10
==> ...

1858 - | 1766 -


© 2015-2024 lektsii.org - -

: 0.372 .