, . PASCAL STRING. . String ASCII 255 .
string
Var B: string [30]; { , 30 }
st: string; { 255 }
.
, , :
- i- ;
- , ;
- , ;
- , ;
- ;
- , ;
- ;
- .
.
function Concat (s1 [, s2,..., sn]: string): string;
.
: WriteLn (Concat ('ABC','DEF')); { 'ABCDEF' }
function Copy (s: string; index: Integer; count: Integer): string;
.
:
var s: string;
begin
s:= 'ABCDEF';
WriteLn (Copy (s, 2, 3)) { 'BCD' }
end.
function Length (s: string): Integer;
.
s:='Welcome to Pascal';
WriteLn (' = ', length (s)); {17}
function Chr (x: Byte): Char;
ASCII.
function Pos (substr: string; s: string): Byte;
.
var s: string;
begin
s:= ' 123.5';
{ }
while Pos (' ', s) > 0 do
s[ Pos (' ', s)]:= '0';
end.
procedure Delete (var s: string; index: Integer; count: Integer);
.
var s: string;
begin
s:= 'Honest Abe Lincoln';
Delete (s,8,4);
WriteLn (s); { 'Honest Lincoln' }
end.
procedure Insert (source: string; var s: string; index: Integer);
.
var s: string;
begin
s:= 'Honest Lincoln';
Insert ('Abe ', s, 8);
WriteLn (s); { 'Honest Abe Lincoln' }
end.
procedure Str (x [:width [:decimals ]]; var s: string);
, Write.
:
function IntToStr(i: Longint): string;
{ }
var s: string [11];
begin
Str (i, s);
|
|
IntToStr:= s;
end;
begin
WriteLn (IntToStr(-5322));
end.
procedure Val (s: string; var v; var code: Integer);
, Read. S - ASCII , v - real Integer, , code - Integer.
:
var str: string;
i, code: Integer;
begin
str:='123.456';
Val (str, i, code);
{ ? }
if code <> 0 then
WriteLn (' : ', code)
else
WriteLn (' = ', i);
end.
.
:
, ( ) , .
1. .
2. , .
3. .
4. . . , , .
5. child children.
6. . , .
7. , .
8. , , .
9. . .
10. .
11. , .
12. .
13. . , .
14. . .
15. . .
16. , .
17. , . , .
18. , , .
19. ( ) .
20. .
21. . ( ) , .
N 6.
. , . . Pascal . , , . , .. , , .
|
|
, , :
< > file of <>
:
Var FT: file of char;
FileInp: file of real;
FileOut: text;
: , . , .
:
Program File_Example;
var F1: file of integer { }
F2: text { }
R: integer;
st: string;
...
begin
Assign (F1, 'FileInp.dat');
Assign (F2, 'FileOut.dat');
Reset (F1); { F1 }
Rewrite (F2); { F2 }
........
Read (F1,R); { F1 }
........
writeln (F2, St); { F2 }
........
Close (F1); { }
Close (F2);
end.
.
. , .
.
1. F. G, F () ().
2. F, . G, F .
3. F, . . F , . H, F G , G
.
4. F, . . F , . H, F G , G , .
5. F, . . F , . H, F G , G -
: , , , .. (, 4).
6. F. , 100. 50 . G : 1- , 51- , 2- , 52- ,...50- , 100- , (
) 101- , 151- , 102- , 152- ,..., 150- , 200- ..
7. , , : , ,.... .
8. , , : , ,.... ...
|
|
9. , 5000 . . 100 .
10. F 1 F 2. F 1 . . F 2 40 , . : , - . F 1
. G.
11. ( ), . F, . , , - .
12. ( ), . F, . , .
13. ( ), . F, . : .
14. , . 40 . ( ).
15. , . 50 . , 50 .
16. F, . 0. : 10 , 10 .. F G , G : , ..
16. F, . 0. : 10 , 10 .. F G , G : , .. (, 40).
17. F, . G 20 , - 20 .. 20 , G F, .
18. . .
19. . , . , .
20. F, G. , F G. , , F G . , N (N >0) ( ) , N +1.