Davydov G.v. Programmirovanie i Osnovy Algoritmizacii (2003)

download Davydov G.v. Programmirovanie i Osnovy Algoritmizacii (2003)

of 449

  • date post

    29-Nov-2014
  • Category

    Documents

  • view

    123
  • download

    0

Embed Size (px)

Transcript of Davydov G.v. Programmirovanie i Osnovy Algoritmizacii (2003)

..

, ,

2003

'

004.4 32.965 13: - ( ) (. , - . , . .. ); . . , . - .

13

, .. : . /.. . .: . ., 2003. 447 .: . ISBN 5-06-004432-7

, 5502 6519 . ( 1), C++ ( 2) ( 3). 20 , . - -, , . , 210100 . 004.4 32.965 . , . 06236 09..01 . -183. 14.08.03. 60x88Vi6. . . . . 27,44 . . ., 27,94 . .-.. 3000 . 3184. , 127994, , -4, ., 29/14. .: (095) 200-04-56. E-mail: mfo@v-shkola.ru http://www.v-shkola.ru : (095) 200-07-69, 200-59-39, : (095) 200-03-01. E-mail: sales@v-shkola.ru -: (095) 200-33-36. E-mail: bookpost@v-shkola.ru . .. . 214000, . , - . . , 2. ISBN 5-06-004432-7 , 2003

- , () .

" " , 5502 6519 " ". , " ", . , . , . C++ ( - ) . , , ( ) . , , , , .. : ; ; ; ; " ", . 20 , . , , , . , -, -, ,

. : 1. , 130 ( 5502 " ") ( 6519). , . 2. , 65 . : , . 1.2, 6.6, 6.8, . 7, 8 ( . 8.1), 10, 11, 12 ( . 12.112.6), 15 ( . 15.8 15.9), 16 17 ( . 17.4); , .1.2.1 .1.2.3. 3. , 100 . , , , . , davydov@aivt.ftk.spbstu.ru.

1. () , . - . - : + = , . - , .

1.1. . . , - "" "". , : "" " 1 " , - . , , , . - . . () . - . - , () . . "^" - , . , \idi3b\bdiQMOQ :

A^^j^ - , 'V"; ^/ - ( ); + 1 - . , , :) = ^ { } ( ) && : = + = - = *= /= %= = = &= 1= '^= [ ] ++ - ,

J..

C++

:: // .* ->* .

() +

. 10. - (), . . 10 /++ - " ". , , , (, "+=" " = " ) . . 1 1 , . . ,

28

, . . ( ). , . 10, /++, , . . 1. ( . , -60). 2. ( . , ). . 11 , . . : "::=" - , " "; - "::="; I - ""; ( ) , ""; { } , , , .. , ; [ ] , , . . 11 , , , . , C++ . . , , ALPHA alpha - . . 11. - , , . , , - . . , . , , .

29

. ::= A|B|C|...|Z ::= a|b|c|...|z _

. _

-> ::= ( | )

^ ^ J __

^

-__>

1|2|...|7

-_> ::= ( |0 )

_ _ _

1I

::= ( |8|9 )

__ _ _

X

:;= ( |0 )

_ __

I ::= ( |_ ) { ( | |_)}

!!! 8! !!! >.

_

-

. 1 1. (), , , . -

30

/++.

2.3. /++ /++ : ; ; . () ; ; ; . . , .

2.3.1. . 12.

-

>Ci*

. 12. - , "", :/ * '' */

/-^

"-/ , ANSI :

31

/'* . */ !

!

, "/*" , "*/" . , "*/" . C++ :/ /

./* // // /* ! - ! */ - */

!X = Y//* */Z;

:X = Y/ /->" ^/ Z;

2.3.2. (. . 11). . . 3. 2.3.3. , /++. . C++:asm

case const delete dynamic32

auto catch constdo

cast

cast

else

bool char continue double enum

break class default explicit

export for Inline namespa.ce protected return static template try vmion void.

extern friend int new public short static_cast this typedef unsigned volatile

false goto long operator register signed struct throw typeid using wchar t

float if xmitable private reinterpret^cast sizeof switch true typename virtual while

Cu/C++, ANSI, , . . , (), . 2.3.4. . 13. _

#i

_

.

. 13. , , ^ /++. . (. 14) . . . , 33

, ( ). , . 15 17. . "/" "L" , ( 2, 4 ). 4 . , ._ _

._ #J ._

. 14. _ ._._ _ 11 -1028 57944L

. 15. _

2>-

013 02000 0160000L . 16.

._

34

_

\ )

^ ^

_

]

0X400 OxEOOL

._

. 17. . ( , 1 ). , , . . - -32768 +32767, - ^ ^ ...-^^ i;; - 0...(2'^-1), - 0...(2^2 _]) ^""-^ +(2 -1)) 0...(232 _]) . . 18. . float 4 , , 8 23 . - 1,0, 2,0. 35

pa 1, . double, 8 , 11 52 . , . long double 10 . , fe . C++, / F, /, L, double (8 64 l,710~^^..l,7 ^'*^^). / F, float, 4 3,410'^^..3,410^^^. , / L long double, 10

___ F-

F-

F-

Hh F-

F-

10. 0.0054 .0054 5.5-3

.. 10.F 0/00541 . 0.0054L

-

_

. 18.

36

. ( ). 256 , : ; . , . , , , . /+- , , , . (. 5). 255. ' \ 0 ' . : ':' ' ' . 5. () \ V

\/\v \b

Y \\ \ \'\_ \_

. , . , . . , . . 19 . :37

" \t" " ,,

:

\07'

, , - ."" \ , 255 \0

. 19. 2.3.5. - - - . . . . - . 20.- ( )

( )

. 20. - 38

"" /+-*- " ", "" "", . . 20, /++- ( main) . . . ++. () . , '\ ' . , V ^include // - // // stdio.h // : // // void convert( nt ) ;

// // int main ( void ) / / {

ch; // // , // printf print f ( "\ " ". \" ) ; printf( "\ " "Enter. \" ) / ch = getchar( ) ; // while ( ch != '\' ) // '\' Enter{

// ch , // 16- . // , // convert ( ch ) ; ch = getchar( ) ; // }

printf( return

"\ 0;

.

\" ) ;

//

,

39

void{

convert nt

( ch ) //

printf( " 10 8 16 \" ) ; // .. 31, // ' ' 32 f ( c h < ' ' ) printf( " () : \" ) ; // , // %, // %d, // % 16- % . // // print f( "% %d % % \",

ch, return;}

ch,

ch,

ch ) ;

, , , , , .. . - main. . main - . (), main, . . , (main , convert - ch). , "{" " } " . , . , . , . . . .

40

2.4. - /++ /++ . - /+- , -. - . : - ; - ; - . - . 2.4.1. - - - , (, ..). , - . - . 1. . 2. . 3. . 4. . 5. . 6. - ( ). - include stdio.h:^include

stdio.h. -, , , - .

41

. . 7(^^, :^include FILE * fopen ( const const char *path. ); // // // // //

cha.i: *type

path type. type . 6. /open . (NULL) . . . 6. type "" 'V' "" V+" "w+" "+" . , . , (). , ( , - ) . , (). ,

. fclose(), :ilnclude nt fclose( FILE stream / / // ) ; / / EOF

. . - :42

( stdin); ( stdout); ( stderr); ( stdaux); ( stdprn). stdin , stdout stderr - , stdaux - stdprn - . -, . . , , . 7. . 7. stdin fread fgetc fgetchar getw /gets fscanf stdout fwrite fputc fputchar putw /puts /print/ v/print/

getc getchar

put putchar ungetc puts print/ vprintf

int ,

gets scan/

sscanf

sprint/ vsprint/

1

, , scan/-/scan/ printf-fprint/ 2.4.2. scanf-fscanf . - , . /*- 1 () .

43

-^ " exl dat" : 1 // OxFA float long char "exl. dat")12; f; 1; ch.

.

str[

20 ];// " " (

// -22 // 074 // 1.57 // -125874 // 'Z '

-/ ^^Include int{

)

// //

-

main ( void int float long char FILE int

i, 11^ 12; f; 1; ch, str[ 20 *f_ln; // // ret code; //

]; fscanf

// exl.dat f_ln - fopen( "exl.dat", "" ) ; if( f__ln -= NULL ) { // printf( "\n exl.dat . return 1;}

" ) ;

// exl.dat retcode = fscanf( f_ln, " 1 = % ll=%d 12=% f=^%f l = %ld ch^%c str=%s%c%s", &1, Sell, &12, &f, &1, &ch, str, &str[3], &str[4] ) ; if( retcode != 9 ){

print f ( "\n return 2; return}

fscanf

."

) ;

; 1 exl.dat: 12=074

//

l=OxFA 11=-22 f==1.57 1 = -125874 str=HaM ch=z

44

fscanf? "...". " " ( '\' \'), ( ) , . , "%", .