.


:




:

































 

 

 

 





. . , , , , . , , , .

int func1(int x) { x=x+1; return x; }

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

void func2(int &x) { x=x+1; }

. . , . , . , , . , 68.

. , . , , . .

( ), ( , , C++), ( 68). ( var ). , (), ( , ), , - , .

 

, , : , , ( ), .

: .

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

, .

, , . - , , ; , - -.

33

String () . Array [0..N] of Char. N 0 255. , , 1 N. 0 , .. , .

, String[K], K - 255. K. . , , , "+".

. , . . : .

'abcd' > 'abcD' { 'd'>'D' }

'abcd' > 'abc' { 'd'>'' }

'abc' < 'axxc' { 'b'<'x' }

'abcd' = 'abcd'

(String) (Char). , S: string; C: char; S:='', S[1]='', S[2]='' . . , : C:= S[1]; . , , :

for i:= 1 to N div 2 do

begin

C:= S[i];

S[i]:= S[N-i+1];

S[N-i+1]:= C

Writeln(S);

end; { : "" }

N:= ord(S[0]); - "S" S[0]. "ord" . N div 2 - "N" . "C" i- , , .

 

, :

for i:=1 to N do if S[i]=' ' then writeln (' ');

for i:=1 to N do if S[i]='/' then S[i]:='\'; { "/" "\"}

() . , , . :

for i:=1 to N do S[i]:= chr(ord(S[i])+2);

{ }

, MS-DOS ASCII 0 255. Pred(C); Succ(C);

.

Length(s) s.

Concat(s1,s2,..,sn) s1+s2+..+sn.

Copy(s,p,k) s, p k.

Pos(s1,s) s1 s s1 s 0 .

Delete(s,p,k) s , p k.

Insert(s,s1,p) s s1, p.

. Str(X:n:d,S) Val(S,X,e). X S , n d . n d . S X. e=0.

: .

var s,x,y,z: string;

begin

x:= 'turbo';

y:= 'pascal';

z:= x+' '+y; { z='turbo pascal' }

s:= ''; { }

for c:='a' to 'z' do s:=s+c; { s='abcd..xyz' }

writeln(s);

end.

35

- , . , . :

 

 

;

;

, .

, . , , . . , .. , .

VAR, TYPE. , , . - .

:

Assign ( ) , .

Reset - .

Rewrite ( , ).

Close - .

EOF ( ), True, , False .

, ASCII. . . . . , . . text. :

Readln (f, st)- st f ;

Writeln (f, st)- st f ;

Append (f) - , f ;

Eoln (st)- , TRUE, st.

1. , 3 . , . .

Program File_text;

var

f1: text;

st: string;

n: byte;

begin

assign (f1, 'file1.txt'); { file1.txt f1 }

rewrite (f1); { file1.txt }

writeln (f1, ' '); { }

writeln (f1, ' ');

writeln (f1, ' Pascal ');

close (f1); { }

reset (f1); { }

while not eof (f1) do { f1}

begin

readln (f1, st); { f1 }

writeln(st); { }

n:= length (st); { }

writeln (' =',n);

end;

close (f1); { }

end.

, () . , . , 0 ..

:

1) Write Read- .

2) Seek ( , ); .

3) Truncate ( ); , , .. , , .

4) Filesize ( ); Integer , .. .

5) Filepos ( ); Integer .

:

Readln (a);

Seek (f, filesize (f));

Write (f, a);

, .. . Write . Reset (f).

, , , Seek. Read, - Write (.. Read ).

 

: C 10 (, ... ). , , , .

 

Program file;

Type

wed = record { wed 3 : n, fio, bal}

n: byte; fio: string[15];

bal: array [1..3] of byte; { bal 3 }

end;

Var spisok: wed; { spicok wed}

sp: file of wed; { wed}

procedure vvod; { }

var i,j:byte;

begin

{ assing }

rewrite (sp); { }

with spisok do

For i:=1 to 10 do begin

n:=i;

writeln (' - ', i); readln (fio);

writeln (' 3 ', fio); For j:= 1 to 3 do readln (bal [j]);

write (sp, spisok); { }

end;

close (sp); { }

end;

procedure print; { }

var j: byte;

begin

reset (sp); { }

writeln ( : );

while not eof (sp) do

with spisok do

begin

Read (sp, spisok); { }

write (n,' ',fio); { }

For j:= 1 to 3 do write (' ', bal [j]);

writeln;

end;

readln;

close (sp);

end;

procedure work;

var num: integer;

begin

reset (sp); { }

writeln ('= '); readln (num);

seek (sp, num-1); { ( 0)}

read (sp,spisok);{ . }

write ('fio='); writeln (spisok.fio);

seek (sp,filepos(sp)-1); { }

writeln ( ); readln (spisok.fio);

write (sp, spisok); { }

close (sp);

end;

 

begin { }

assign (sp,'Vedom.DAT'); { - sp Vedom.dat}

vvod; print; { }

work; print; { }

readln

end.

:

 

 

;

;

.

. :

file of - ( );

text - ;

file - .

:

var

f1: file of char;

f2: file of integer;

f3: file;

t: text;

 

36

Pascal-

, , , .

()

. , , . , 7.0 :

( )

:

:

(+);

(-);

(*);

(mod);

(div);

;

(+);

(-).

:

(=);

(<>);

(<);

(>)

(>=);

(<=).

, , - , ( ). ( !), .

. , / div. , / , ( , 8 2, .. 8/2=4.0). div , .. .

()

, . . , . : X= {+|-}MP{+ | -} r, M ; r (r ); P . , 2-1 ( ) : 2*10-1=0.2, 1.2345 : 1.234*105=123400.0.

, , :

real 4 . 3 , .

:

:

(+);

(-);

(*);

(/);

;

(+);

(-).

 

 

:

(<>);

(<);

(>);

(>=);

(<=).

, , single, double extended . .

comp, . , comp , 19..20 . comp : , ..

() . integer, real. , :

Var X: integer; Y: real;

Y:= X+2;

, , , . real integer . , integer real: integer 2 , real 6 . real integer : round(x) x , trunc(x) .

: - Byte, ShortInt, Word, Integer LongInt; - Single, Real, Double Extended; Comp. 1 ( 1.5e-45 1.5, 10 -45, - ).

 

1

 

 

 

 

 

 

Byte 0...255 - 1

ShortInt -128...127 - 1

Word 0..65535 - 2

Integer -32768...32767 - 2

LongInt -2147483648...2147483647 - 4

Single 1.5e-45...3.4e+38 7-8 4

Real 2.9e-39...1.7e+38 11-12 6

Double 5.0e-324...1.7e+308 15-16 8

Extended 3.4e-4932...1.1e+4932 19-20 10

Comp -9.2e18...9.2e18 8 8

 

Byte Word , ShortInt, Integer LongInt - , Single, Real, Double Extended - . Comp -2 63 +1 +263-1, , Comp . Comp , , .

 

16- , 16- $ 16- : 0-9,A-F. , 255 $FF. Integer LongInt. , , -1.234, , , -1.234E-5 55512.

 

, , . ( ) , .. . :

 

VAR ,..., : ; ,..., : ;...

 

- (), - , VAR - , , . , , . . VAR . . , , i () , , 100. i , - Byte ShortInt, . ; , , , . Real, , Real , .

 

b1,b2,b3,b4 Byte, i,j,k Integer r1,r2 Real. , , :

 

VAR b1,b2,b3,b4: Byte;

 

i,j,k: Integer;

 

r1,r2: Real;

 

:

 

VAR b1: Byte;

 

i,j,k: Integer;

 

VAR r1: Real;

 

VAR b2,b3,b4: Byte;

 

r2: Real;

 

.

 

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

 

? :

 

:= ;

 

- . - , - . ";", END. ";", . - , , , , . , , .. . , , + ( ). :

 

1 ( );

 

b1 ( );

 

25+1E3

 

b1+4.25+r2

 

:

 

i:=-11; j:=22+i; k:=i+j+177;

 

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

 

CONST =; =;...

 

- , - , , , , . :

 

CONST C=-155;

 

D=C+100;

 

E=1E2+C+D;

 

CONST F=D+1;

 

CONST G=C+F;

 

, , , . "" - , , - , . C,D,F G Integer, E - Real. - , :

 

CONST :=; :=;...

 

, , (, ) . , , , . :

 

CONST t:Word = $FFFF; b:Byte = 11; r:Real = 1.23E-16; z:Integer = 0;

 

BEGIN t:=t-1; END.





:


: 2016-10-06; !; : 1499 |


:

:

, .
==> ...

951 - | 880 -


© 2015-2024 lektsii.org - -

: 0.18 .