of 52 /52
Министерство образования и науки Украины Национальный технический университет "Харьковский политехнический институт" МЕТОДИЧЕСКИЕ УКАЗАНИЯ к лабораторным занятиям по курсу "Основы программирования" для студентов специальности 7.080402 "Информационные технологии проектирования" Утверждено редакционно-издательским советом университета, протокол 1 от 30.03.07. Харьков НТУ "ХПИ" 2007

Lab Osnov Program

  • Author
    0brain

  • View
    3.086

  • Download
    3

Embed Size (px)

Text of Lab Osnov Program

" "

" " 7.080402 " "

- , 1 30.03.07.

"" 2007

" " 7.080402 " ". / . . . , . . , . . . : , 2007. 52 . . .

:

. . . . . .

. .

.................................................................................................... ................................................. 1. ............................................................................ 1. ................. 2. .......................................................... 2. ............................................................... 3. . String ............................................................................................ 4. .................................................................. 5. .......................................................... 6. .................................................................. 7. ............................................................ 3. ........................................................................................ ...................................................................................... 4 5 5 5 12 12 17 21 32 38 44 50 51

. , , " ". , . 80-90- , (, , ). , -, . , /-80, MSDOS, MSX DOS, Windows .. , , , , . , . , . , . , , , , , , , , . . -, , , . , 4

. " " , . , , . . 1. , , . 2. , , . . 3. , . . 4. , . 1. 1 1.1. : , - . 1.2. integer, boolean, char, real. , .. Succ Pred. . 5

, ( 1.1). . , .;

TYPE

=

1.1. . , , 1 , 2 .. , .. . Month := MAY. , , . , , . type Month = (JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC) ; var M: Month; , , . . . , - . M:=APR; Write (M) ; APR . . Write(Ord(M)). 3, APR .6

. , : if M>MAY and M 0 . 5 C(40) x[i] < 0 . 6 D(80) D . 7 Y(20) y[i] > 0 Y.

15

3 1 2 8 Z(30) R , Z. 9 N(50) N, . 10 X(N) . . 1 1 2 (10,15)

4

n[i]/3*3=n[i] N 40

2

(N,M)

3

B(N,N)

4

C(N,N)

5

D(K,K)

6

D(10,10)

3 4 a[i,j]>0 . . N , >, >=, ''). 4. VarString ''. 5. VarString '', ''.19

6. , " ". , .

1. . 2. ? 3. ? 4. ? 5. ? 6. ? 7. . 8. DELETE, INSERT. 9. . 10. .

. 1. . 2. : , POS, LENGTH, INSERT, DELETE . 3. . 4. .

1. . 2. . 3. . 4. . 5. .20

6. , . 7. .

1. . x. 2. . : a) + *; ) +, -, * . 3. . , : a) ; ) . 4. S. si, si+1, si - , si+1 - . 5. S1 S2. , , S1 S2. 6. . asdf. 7. . , * , *. 8. . child children. 9. . , (, ), {, }. . , . 10. . , ( ). . 4 4.1. :

1. -. 2. 21

.4.2. .

, . , , . : type Text = file of char; Int = file of integer; Text . Text , , . -. , .. : type =file of file of... of , . - , , . - . . () . , ( ). , () -, ( ) . . : , . -. Assign. , , , 22

. , , . , "". Reset, Rewrite. , Reset , , Rewrite, . , , Reset Rewrite. , , ( ) . . . , , Read Write, . Sk, . FilePs Filesize. , Close. . . - . . {$I+} {$I-} . , 23

{$I-}, , , . , -, IResult. , , IOResult. , {$I+}, - IOResult - . : Windows , Windows - -, SetErrorMode(1). . , . , Borland Pascal ( Text) Char. : , , , (end-of-line), , . (read write), , Char. . , Read(f,i), i , , , , i. , Input utput. Input , ( ), utput , ( ). DOS Input utput

24

, : Assign(Input,''); Reset(Input); Assign(Output,''); Rewrite(Output); Windows , Input Output Windows , -. , WinCrt, Input Output . WinCrt , Windows, , WinCrt, , Windows. , , . , Input Output, , . , Read() Read(Input,) Write() Write(Output,). , Assign Reset, Rewrit Append. , Reset, . , , Rewrite Append. . - , , . file . : var DataFile: file;

25

Reset Rewrite , , . 128 . , 1, , ( 1, , ). Read Write , . Read Write Blockrd BlockWrite . FileMode. FileMode, System, , DOS ( ), Reset. FileMode = 2. . FileMode Reset. : , Rewrite, /, Filemode = 2. FileMode DOS. : 0: 1: 2: / DOS 3. , ( " DOS"). 4.1. Assign. Program TM; Var F : Text;Begin26

Assign(F, ''); { } ReWrite(F); WriteLn(F, ' ...'); Close(F); End. 4.2. ReWrite. Program TM; Var F : Text; Begin Assign(F, 'NEWFILE.$$$'); ReWrite(F); WriteLn(F, ' ...'); Close(F); End.

1. . 2. ? 3. . 4. ? 5. ? 6. . 7. ? 8. ? 9. ? 10. ?

. , : ; ; .27

. , , , , . .

1. : 1) DISKSIZE, ; 2) , DOS ( FINDFIRST, FINDNEXT); 3) DOS- , ( ASSIGN); 4) ( REWRITE); 5) , ; 6) ( WRITE / WRITELN); 7) ( CLOSE). 2. : 1) , ( FINDFIRST, FINDNEXT); 2) , ); 3) , DOS- , ( ASSIGN); 4) ( RESET); 5) ( READ / READLN); 6) ; 7) ( CLOSE). 3. : 1) , {$I-}; 2) - IORESULT; 3) - , . 28

1. . 2. . 3. . 4. , . 5. . 6. . 7. . 8. . 9. . 10. .

1. . , . , , . - . . , . . 2. . , , . , , ( , ..). . . , . , , , . 3. . , , , , . , , , . .29

. S, Sb, Sc A, B, C , : - , , , ; - ; - . 4. . , . , , . . . . . . 5. . , . , , , , 25, .. . . . , 1 3 . . , . . , , . 6. . , . , , , : "1" , "0" . 30. . . , "5" , ( 50 %), 25 %. , "4" "5" , . , "3", , , . . 7.30

. , . , , ( "" , "" ). 25. . . , , . 8. . , . , , , , ( , ..). . . : 1) Y; 2) Z, ; 3) , . , Y, Z, XX ; 9 . , . , , , , . . . ; Y. , Y . 10. . , . , , , . . , , P . . , ; . .

31

5 5.1. :

1. . 2. .5.2.

, . , : type CharSet = setof'A'..'Z' , -, - Z. : type NumberSet = set of 0..50 , , , 0 50. . : type SymbolSet = set of ' '..' '; Colour= (WHITE, BLUE, RED) ; ColourSet=set of Colour ; T1 = set of 0..9 ; var C : colour; CoISet: ColourSet; T: integer; TSet: T1; 0 9, TSet 0 9. :32

(" + "); (" * "); (" "); in. in , . , in, (.. , ). , in, . : RED in [RED, WHITE] true 8 in [0..3, 6, 9] false - , . , ( ). , , , , , ( ). : ColSet := [WHITE, RED] ; ColSet := [] ; TSet := [1,7,5] ; TSet:=[1..5,8]; Tset := [8 mod 4,15 div 5] =, , =. = , . >=