.


:




:

































 

 

 

 


7. -.




6. (string).

. (string), , , . 80 . , , . . . , .

: , , .

-. . , , . :

1. ( ) .

2. . .

3. ( ).

4. .

5. .

. , , ( , ). .

//

function Input: string;

begin Input:= ' , ?'; end;

//

procedure Select (S: string; R: string; var M: array of string; var n: shortint);

begin end;

//

function Sborka (Slova, Znaki: array of string; Ns,Nr: shortint): string;

begin Sborka:= ''; end;

//

procedure PrintResult (Predl, Res: string);

begin end;

//

const N = 20; //

var

Predl, //

Razd, //

Alph, //

Res: //

string;

Slova: array [1..N] of string; //

Znaki: array [1..N] of string; //

Ns, Nr: shortint; //

begin

//

Predl:= Input;

Razd:= ',./;!?';

Alph:= ''+

'';

//

Select (Predl, Razd, Slova, Ns);

Select (Predl, Alph, Znaki, Nr);

//

Res:= Sborka (Slova, Znaki, Ns, Nr);

//

PrintResult (Predl, Res);

Readln;

end.

. .

(Select) ( ). . , .

. ( , ):

1. -1, .

2. , 3, .

3. .

4. (SelectWord) . .

5. , 2.

(SelectWord). , , Select. , , , , :

1. .

2. .

3. ( ).

. :

1. - ( ).

2. , - , .

:

1. , , , n, 0.

2. , 3-.

3. .

4. ( 0), , n=0 , n, .

(CopyWord) . 0, 1- , ( ). . .

:

type

TCharSet = set of char;

//

function Input: string;

var s: string;

begin

writeln (' ');

readln (s);

Input:= s;

end;

//

function FillCharSet (s: string): TCharSet;

var i: byte; Rset: TCharSet;

begin

Rset:= [];

for i:= 1 to length(s) do Rset:= Rset + [s[i]];

FillCharSet:= Rset;

end;

//

procedure DelRazd (var S: string; R: string);

var i: byte; Rset: TCharSet;

begin

// -

Rset:= FillCharSet(R);

//

while (S<>'')and(S[1] in Rset) do Delete(S,1,1);

end;

//

function FindIndex (S, R: string): byte;

var i,k,n: byte;

begin

n:= 0;

for i:= 1 to length(R) do

begin

k:= Pos(R[i],S);

if k > 0 then

begin

if (n = 0) or (k < n)

then n:= k;

end;

end;

FindIndex:= n;

end;

//

function CopyWord (var S: string; n: byte): string;

var Sl: string;

begin

if n > 0

then Sl:= Copy(S,1,n-1)

else Sl:= S;

//

if n > 0

then Delete(S,1,n)

else S:= '';

CopyWord:= Sl;

end;

//

function SelectWord(var S: string; R: string): string;

var i,n: byte; Rset: TCharSet;

begin

//

DelRazd(S,R);

//

n:= FindIndex(S,R);

//

SelectWord:= CopyWord(S,n);

end;

//

procedure Select(S: string; R: string;

var M: array of string; var n: shortint);

begin

n:= -1;

while S <> '' do

begin

inc(n);

M[n]:= SelectWord(S,R);

end;

end;

function Sborka(Slova, Znaki: array of string;

Ns,Nr: shortint): string;

var Rez: string; s,z: shortint;

begin

Rez:= '';

s:= Ns; z:= -1;

while (s >= 0) or (z <= Nr) do

begin

if s >= 0 then

begin

Rez:= Rez + Slova[s];

dec(s);

end;

if z <= Nr then

begin

inc(z);

Rez:= Rez + Znaki[z];

end;

end;

Sborka:= Rez;

end;

procedure PrintResult(Predl, Res: string);

begin

writeln(' - '#13, Predl);

writeln(' - '#13, Res);

end;

const N = 20;

var

Predl, Razd, Alph, Res: string;

Slova: array [1..N] of string;

Znaki: array [1..N] of string;

Ns, Nr: shortint;

begin

//

Predl:= Input;

Razd:= ',./;!?';

Alph:= ''+

'';

//

Select (Predl, Razd, Slova, Ns);

Select (Predl, Alph, Znaki, Nr);

//

Res:= Sborka (Slova, Znaki, Ns, Nr);

//

PrintResult (Predl, Res);

Readln;

end.

1. .

2. , .

3. .

4. . .

5. .

6. , .

7. , .

8. , , .

9. . .

10. .

11. .

12. , .

13. . . - .

14. , .

15. , :

123434 53423 2344 6564.

.

 

7. -.

. 5 6, ( ), .

:

1. .

2. .

3. ,

(ParamCnt, ParamStr).

4. .

5. .

1. , (CRT), , ( Windows exe, Unix ). , 6.pas, 6.exe.

, . , 6.txt. , . :

_ <__ >__

:

6.exe <6.txt >6_1.txt

: - .

2. : (Input) (PrintResult). .

:

var

s: string; //

Fi, Fo: Text; //

begin

Assign (Fi, '7.pas'); // Fi 7.pas

Reset (Fi); //

Assign (Fo, '7.txt'); // Fo 7.txt

Rewrite (Fo); //

while not (eof(Fi)) do // Fi

begin

Readln (Fi, s); //

Writeln (Fo, s); //

end;

Close (Fo); // Fo

Close (Fi); // Fi

end.

3. : ParamCount, ( ), ParamStr(Num), Num . , , , , . , . , , .

Program p7_1;

//

procedure CopyFile (var Fi, Fo: Text);

var

s: string;

begin

while not (eof(Fi)) do

begin

Readln (Fi, s); Writeln (Fo, s);

end;

Close (Fo); Close (Fi);

end;

//

procedure OpenFile (var F: Text; Name: string; Mode: char);

begin

Assign (F, Name);

case Mode of

'r': Reset (F);

'w': Rewrite (F);

'a': Append (F);

end;

end;

var

Fi, Fo: Text; Name1, Name2: string;

begin

//

if ParamCount = 2 then

begin

Name1:= ParamStr (1);

Name2:= ParamStr (2);

OpenFile (Fo, Name2, 'w');

end;

if ParamCount = 3 then

begin

Name1:= ParamStr (2);

Name2:= ParamStr (3);

OpenFile (Fo, Name2, 'a');

end;

OpenFile (Fi, Name1, 'r');

CopyFile (Fi, Fo);

end.

p7_1.exe, ( ) . , , .

p7_1.exe file1 file2

p7_1.exe append file1 file2

: 6 .

4. 5, . .

 

 

.

1. assign.

2. reset.

3. rewrite.

4. append.

5. close.

6. eof.





:


: 2016-12-06; !; : 367 |


:

:

, .
==> ...

1748 - | 1552 -


© 2015-2024 lektsii.org - -

: 0.107 .