.


:




:

































 

 

 

 


244.244. , .




: , . , . , , .

, . , , , , , .

: , . ֳ , , 1: , , .. (-, -, -, --). , . , : . .

, , , 쳺 . , . , , , , . , ᒺ . , . , , , , . wwod. , , , ij!

pol .

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

: , , (-, -).

: (-, -).

: , (-, --).

: , , , , .

, . , ( !), . , .

program perenos;

uses dos, crt;

var alfavit, golosni, prig, drugi: set of char;

slovo, maket: string;

i, j, k, k1, k2, kolgolosni, kolperenos: integer;

pol: array[1..10] of byte;

ch: char;

procedure wwod;

begin

slovo:= ;

repeat

ch:= readkey;

if ch in alfavit then

begin

slovo:=slovo+ch;

write(chr(ord(ch)));

end

else if ch = then

begin

ch:= chr(243); slovo:= slovo+ch;

write(chr(ord(ch)));

end

else if ch = then

begin

ch:= ; slovo:= slovo+ch;

write(chr(ord(ch)))

end

else if ch = then

begin

ch:= chr(245); slovo:= slovo+ch;

write(chr(ord(ch)));

end;

until ch = #13;

writeln;

end;

begin

clrscr;

prig:=[,,,,,,,,,,,,,,,,,,,];

golosni:= [, , chr(243), , , chr(245), , , , ,];

drugi:= [, ];

alfavit:= prig + golosni + drugi;

write( : );

wwod;

kolgolosni:= 0;

maket:= '';

for i:= 1 to 10 do pol[i]:= 0;

k:= 1;

for i:= 1 to length(slovo) do

begin

if slovo[i] in golosni then

begin

inc(kolgolosni);

pol[k]:=i;

inc(k);

end

else if slovo[i] in drugi then pol [ k - 1]:= i;

end;

dec(kolgolosni);

kolperenos:= 0;

{ }

for i:= 1 to kolgolosni do

begin

k1:= pol[i];

k2:= pol[i+1];

{ 1. }

if slovo[k1] in drugi then

begin

slovo:=copy(slovo,1,k1) + - + copy(slovo,k1+1,length(slovo)-k1+1);

for k1:=i+1 to k-1 do inc(pol[k1]);

inc(kolperenos)

end

else

{ 2. , }

if (k2-k1=1) and (length(slovo)-k2>0) then

begin

slovo:=copy(slovo,1,k1) + - + copy(slovo,k1+1,length(slovo)-k1+1);

for k1:=i+1 to k-1 do inc(pol[k1]);

inc(kolperenos)

end else

{3. }

if (k2-k1=2) and (k1<>1) then

begin

slovo:=copy(slovo,1,k1) + - + copy(slovo,k1+1,length(slovo)-k1+1);

for k1:=i+1 to k-1 do inc(pol[k1]);

inc(kolperenos)

end else

{4. }

if k2-k1=3 then

begin

slovo:=copy(slovo,1,k1+1) + - + copy(slovo,k1+2,length(slovo)-k1+1);

for k1:=i+1 to k-1 do inc(pol[k1]);

inc(kolperenos)

end

else

{5. }

if k2-k1>3 then

begin

slovo:=copy(slovo,1,k1+1)+ - + copy(slovo,k1+2,length(slovo)-k1+1);

for k1:=i+1 to k-1 do inc(pol[k1]);

inc(kolperenos)

end

end;

if kolperenos = 0 then writeln( ) else

if kolperenos = 1 then writeln( 1 )

else if kolperenos < 5 then writeln( ,kolperenos, )

else writeln( ,kolperenos, );

writeln( : ,slovo);

readln;

end.

, , , . , , , , , : , .

, . , , !

 

 

, . :

Ø , (, , , , );

Ø , (, , , , , , );

Ø ( , , , ) ..

. , ᒺ , . , Record. , :

Type { }

Book = Record { }

AuthorFamile: string[20]; { }

AuthorName: string[15]; { }

Title: string[90]; { }

Date: word; { }

Page: integer; { }

Klass: byte; { }

End; { }

:

Book

 

AuthorFamileAuthorNameTitleDatePageKlass

, , (). , , , Date, Day (), Month (), Year ().

, BookOld BookNew Book . ³, , . , , , Year, BookNew.Year:= 1999. , , , , .

, , .

: 245. 245. .

: , , , . , .

, , . , , , . :

Program demoRecord;

uses dos, crt;

const n = 10;

Name: array[1..n] of string[15] = ('','',

'','','','',

'','I','I','');

Type Abonent = Record

FName: string[15];

Phone: integer;

end;

Var Klient: array[1..2*n] of abonent;

i, kol: integer;

o, m: byte;

Procedure NewKlient;

begin

inc(kol);

write('i : '); readln(Klient[kol].FName);

write(' : '); readln(Klient[kol].Phone);

writeln;

end;

Procedure EditKlient;

begin

write(' : '); readln(m);

if (m > kol) or (m<1) then writeln(' i!')

else begin

write(' : ');

readln(Klient[m].Phone);

end;

writeln;

end;

Begin

for i:= 1 to n do

begin

Klient[i].Fname:= Name[i];

Klient[i].Phone:= Random(10001)+20001;

end;

kol:= n;

writeln;

repeat

for i:= 1 to kol do writeln(i:2,'. ',Klient[i].Phone,' - ',Klient[i].Fname);

writeln;

write('1- 2- 3-i ');

readln(o);

if o = 1 then NewKlient;

if o = 2 then EditKlient;

until o > 2;

end.

, , , . , , . , . , , 15 . ? ͳ , FName . , Ⳕ , . , , , . . , Integer, .

22222. , , . , , String, Integer. , .

, , . with, with .

, ,

...

Klient[i].Fname:= Name[i];

Klient[i].Phone:= Random(10001)+20001;

...

:

...

with Klient[i] do

begin

Fname:= Name[i];

Phone:= Random(10001)+20001;

end;

...

with , .

 

 

 

. , , . , .

ϳ , . , , : ( ), , . , , , .

( !). .

: , . , . , .

Assign(f, Name);

f , Name , . , .

Assign , , . , Assign .

Assign . : , . Name, , .

:

) CON , , . Input Output, Interface System, Con, :

Assign(Input, 'CON');

Reset(Input);

Assign(Output, 'CON');

Rewrite(Output);

ϳ Write Read Input Output.

) PRN .

: 246. 246. , 32- 255-.

: , , .

var

txt: text;

i: integer;

st: string;

begin

Assign(txt, 'PRN');

Rewrite(txt);

writeln(txt,' : ');

for i:= 32 to 255 do

begin

st:= chr(i);

write(txt,st);

if i mod 40 = 0 then writeln(txt,'');

end;

Close(txt);

end.

, .

, Assign . , , .

. :

Reset(f); .

Rewrite(f); .

f . , . IOResult. , , .

Reset . ( text) . RecSize word, . Reset :

Reset(f, RecSize);

Rewrite . . , Rewrite . , , ﳿ , 䳿.

Rewrite RecSize word. :

Rewrite(f, RecSize);

Rewrite , .

.

Close(f);

, f , , 䳿: .

: 247. 247. , Demo.txt 32- 255-.

: , .

var

f: text;

i: integer;

st: string;

begin

Assign(f, 'DEMO.TXT'); { }

Rewrite(f); { ³ }

writeln(' : ');

for i:= 32 to 255 do

begin

st:= chr(i);

write(f, st);

if i mod 40 = 0 then writeln(f,'');

end;

Close(f); { }

end.

, () .

Rename(f, NewName) , f , NewName.

Erase(f) , f. , , , .

, IoResult, Integer, . 0, , , . , .

IoResult . , {$I}. .

: 248. 248. INPUT.TXT , . , .

: . , IoResult. , , . (, real) IoResult , , . :

program Pidrachunok;

uses dos, crt;

var f: text;

kol, kod: integer;

r: real;

begin

Assign(f,'INPUT.TXT');

Reset(f);

kol:= 0;

{$I-}

while not(eof(f)) do

begin

readln(f, r);

kod:= ioresult;

writeln(kod,' r = ',r,' kol = ',kol);

if kod = 0 then inc(kol);

end;

{$I+}

Close(f);

write('ii i = ', kol);

readln

end.

, eof(f). True, False . , , , . 䳺 eoln(f), .

Append(f); , , .

, , ? , . ( ) , .

, , , . , , , .

, , :

Type FileRec = Record

FName: string[15];

Phone: integer;

end;

var f: file of FileRec;

: , , . , , . SizeOf(FileRec). , .

Seek(f, N) f N. f . , . , 1, , , , . , Seek, , , . , , , , IoResult.

: 249. 249. , .

: , , , . , , .

. , . , , :

program CreateBasePhone;

uses dos, crt;

const n = 10;

Name: array[1..n] of string[15] = ('','',

'','','','',

'','I','I','');

Type Abonent = Record

FName: string[15];

Phone: integer;

end;

Var Klient: array[1..n] of abonent;

i, kol: integer;

o, m: byte;

f: file of abonent;

Begin

Assign(f,'PHONE0.DBF');

Rewrite(f);

for i:= 1 to n do

begin

Klient[i].Fname:= Name[i];

Klient[i].Phone:= Random(10001)+20001;

write(f,klient[i]);

end;

Close(f);

end.

, Abonent. . , , , .

. , , , :

program BasePhone;

uses dos, crt;

const n = 100;

Type Abonent = Record

FName: string[15];

Phone: integer;

end;

Var Klient: array[0..n] of abonent;

i, kol: integer;

o, m: byte;

f: file of abonent;

Procedure NewKlient; { }

begin

inc(kol);

write('i : '); readln(Klient[kol].FName);

write(' : '); readln(Klient[kol].Phone);

Seek(f,kol);

write(f,klient[kol]);

writeln;

end;

Procedure EditKlient; { }

begin

write(' : '); readln(m);

if (m > kol) or (m<1) then writeln(' i!')

else begin

write(' : ');

readln(Klient[m-1].Phone);

Seek(f,m-1);

write(f,klient[m-1]);

end;

writeln;

end;

Begin

Assign(f,'PHONE0.DBF');

Reset(f);

i:= 0;

while not eof(f) do

begin

read(f,Klient[i]);

inc(i);

end;

kol:= i-1;

writeln;

repeat

for i:= 0 to kol do

writeln(i+1:2,'. ',Klient[i].Phone,' - ',Klient[i].Fname);

writeln;

write('1- 2- 3-i ');

readln(o);

if o = 1 then NewKlient;

if o = 2 then EditKlient;

until o > 2;

Close(f);

end.

. Rewrite Append, , . Seek. Abonent, , ( ) .

. , . , . .

: FilePos FileSize.

FilePos(f) f , , , FileSize(f) f , . longint. , . , , , : Seek(f, FileSize(f)).

, , . . ?

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

, . . , fileofchar fileofbyte. , , . , .

:

Var f: file;

, . , Read Write BlockRead BlockWrite, , ᒺ .

BlockRead(var f:file; var Buf; Count:word {; result:word}); , . Buf , f, Count , . Result .

³ Blockwrite(var f:file; var Buf; Count:word {; result:word}). .

, . ᒺ :

ᒺ = Count RecSize,

RecSize , . ᒺ 64 . , . , , .

, , . , , , ( !). , . , 35 (1,44 )? .

, , , , , , . , , , , , , ᒺ .

 

 

250. 250. f, . :

) , ;

) , ;

) ;

) ;

) ;

) , 3;

) .

251. 251. f g. .

252. 252. f, . g, f ().

253. 253. f . .

254. 254. f, . ϳ g N . :

1 N+1

2 N+2

3 N+3

......

N1 N+N1

N 2N

..

255. 255. . . .

256. 256. , 1 1 .

257. 257. , , .

258. 258. . , .

259. 259. .





:


: 2016-11-18; !; : 436 |


:

:

, ; , .
==> ...

1776 - | 1534 -


© 2015-2024 lektsii.org - -

: 0.226 .