. . .
, With:
with <> do <>
with, do (, ); <> , , , ; <> .
with... do . . :
with c.bd do month:= 9;
with c do with bd do month:= 9;
c.bd.month:= 9.
with. , with... do .
18. . : , , , , , .
, 50 . . :
1) . . (author);
2) (title);
3) , , (city);
3) (year);
4) (cost).
author, title, city . Year . (cost) . entry :
entry = record
author, title, city: string;
year: 1..9999;
cost: real;
end;
50 , entry. (. 16) , ch. . readln. : m[i].author, m[i].title, m[i].city, m[i].year, m[i].cost.
:
program archives;
uses crt;
label 10;
type
entry = record { }
author, title, city: string;
year: 1..9999;
cost: real;
end;
var
m: array[1..50] of entry;
{ 50 }
{, }
i: integer;
ch: char;
begin
i:= 0;
{ }
writeln ( ? [Y]);
ch:= readkey;
if upcase(ch) = Y then
repeat
i:= i+1;
writeln( ); readln(m[i].author);
writeln( ); readln(m[i].title);
writeln( ); readln(m[i].city);
writeln( ); readln(m[i].year);
writeln( ); readln(m[i].cost);
writeln ( ? [Y]);
|
|
ch:= readkey
until upcase(ch) <> Y
else
begin
write ( ? !);
goto 10
end;
repeat until keypressed;
10:end.
19. . .
. ss , (. 17). k. , with... do. . ch = Y.
:
program archives2;
uses crt;
label 10;
type
entry = record { }
author, title, city: string;
year: 1..9999;
cost: real;
end;
var
m: array[1..50] of entry;
{ 50 }
{,
}
i, j, k: integer;
ss: string; { }
ch: char;
begin
i:= 0;
{
}
writeln ( ? [Y]);
ch:= readkey;
if upcase(ch) = Y then
repeat
i:= i+1;
with m[i] do
begin
writeln( ); readln(author);
writeln( ); readln(title);
writeln( ); readln(city);
writeln( ); readln(year);
writeln( ); readln(cost);
end;
writeln ( ? [Y])
ch:= readkey
until upcase(ch) <> Y
else
begin
write ( ? !);
goto 10
end;
k:= i;
{ }
repeat
writeln( ); readln(ss);
writeln( , , ss: 15);
for i:= 1 to k do
with m[i] do
begin
if ss = author then
begin
writeln(title);
writeln( ,city);
writeln( ,year);
writeln( ,cost:8:2);
writeln
end
end;
writeln( ? [Y]);
ch:= readkey;
until upcase(ch) <> Y;
repeat until keypressed;
10:end.
, . , , , , , . . , , , .
, . , .
, , , :
type status = (married, widowed, divorced, single),
, , , . :
type person = record
{ person}
case status of
married: ({ });
single: ({ });
|
|
...
end;
, , ( ), . , . , married single, widowed divorced.
() , . ms: status. . . :
case ms: status of
, , , person, .
1. (name) , (first, last).
2. (height) .
3. (sex) ., . (male, fmale).
4. (date) , , (year, month, day).
5. (depds) .
6. (status):
(married) (widowed):
) (mdate) , , (year, month, day).
(divorced):
) (ddate) , , (year, month, day),
) (firstd) , (false, true).
(single):
.
person :
type
status = (married, widowed, divorced, single);
date = record
year: 1900..2100;
mo: (jan, feb, mar, apr, may, jun,
jul, aug, sep, oct, nov, dec);
day: 1..31;
end;
natural = 0..max;
person = record
name: record first, last: string[15] end;
height: natural;
sex: (male, female);
birth: date;
depdts: natural
case ms: status of
married, widowed: (mdate: date);
divorced: (ddate: date; firstd: boolean);
single: ()
end {person};
. 18.
. 18
(. 19):
. 19
20. .
19 , . entrytype, . type entrytype = (book, magazine).
:
1) (author) string;
2) (title) string;
3) () 1... 1999;
4) (book):
) (publisher) string;
) (city) string.
(magazine):
) (magname) string;
) (vol) integer;
) (page) integer.
:
program archives3;
uses crt;
label 10;
type
entrytype = (book,magazine);
{ , }
entry = record
author, title: string;
year: 1..9999;
case tag:entrytype of
{ tag }
book: (publisher,city: string);
magazine: (magname: string; vol, page: integer)
end;
var
m: array[1..50] of entry;
i, j, k: integer;
ss: string;
ch: char;
begin
i:= 0;
{ }
writeln ( ? [Y]);
ch:= readkey;
if upcase(ch) = Y then
repeat
i:= i+1;
writeln( , Y );
ch:= readkey;
if upcase(ch) = Y then
m[i].tag:= book
{ book}
else
m[i].tag:= magazine;
writeln( ); readln(m[i].author);
writeln( ); readln(m[i].title);
writeln( ); readln(m[i].year);
{ }
|
|
if m[i].tag = book then
{ , }
begin
writeln( ); readln(m[i].city);
writeln(); readln(m[i].publisher);
end
else
{ , }
begin
write ( ); readln(m[i].magname);
writeln( ); readln(m[i].vol);
writeln( ); readln(m[i].page);
end;
writeln ( ? [Y]);
ch:= readkey;
until upcase(ch) <> Y
else
begin
write ( ? !);
goto 10
end;
k:= i;
{ }
repeat
writeln( ); readln(ss);
writeln( , ss: 15);
for i:= 1 to k do
begin
if ss = m[i].author then
begin
writeln(m[i].title);
writeln( ,m[i].year);
if m[i].tag = book then
begin
writeln( ,m[i].city);
writeln( ,m[i].publisher);
writeln
end
else
begin
writeln( ,m[i].magname);
writeln( ,m[i].vol);
writeln( ,m[i].page);
writeln
end
end
end;
writeln( ? [Y]);
ch:= readkey;
until upcase(ch) <> Y;
repeat until keypressed;
10:end.
. , , (, , , ), , , . .
. , , . . . , , 0 256. , , . .
var, type. :
< > = set of < >
< > ; set, of (, ); < > , , word, integer, longint.
:
. 20
:
var
year: set of 198..200;
c: set of char;
Year , 198... 200, .
:
type
digitchar = set of 0..9';
digit = set of 0..9;
color = (red, blue, green, white, black, orange);
brush = set of color;
var
s1, s2, s3: digitchar;
s4, s5, s6: digit;
a: brush;
digitchar 0, 1, 2, 3, 4, 5, 6, 7, 8, 9. digit 1, 2, 3, 4, 5, 6, 7, 8, 9. brush . s1, s2, s3 digitchar, 0 9. s4, s5, s6 1 9 , digit. color. , .
|
|
, , .
, min..max, min max . (. . min > max), , .
, . [ ] (. 21).
. 21
:
[13]
[ i + j, i j ]
[ 0..9']
:
[true, 2] ;
[200.. 300] ord(300) > 255;
[4.0, 5.0] .
, , :
:=
, .
: , , . , , :
+ ();
* ();
, ().
. , , .
in A ; true, , false;
= ;
<> ;
<= ; true, ;
>= ; true, .
, , . , . .
s1:= [1, 2, 3];
s2:= [3, 2, 1];
s3:= [2, 3];
s4:= [0..3, 6];
s5:= [4, 5];
s6:= [3..9];
s1 s2 , s3 s2, .
s4 + s5 [0, 1, 2, 3, 4, 5, 6].
s5 + s6 [3, 4, 5, 6, 7, 8, 9].
s6 s5 [3, 6, 7, 8, 9].
s4 s5 [0, 1, 2, 3, 6].
3 in s6 true.
2 * 2 in s1 false.
, . ,
if (ch = a) or (ch = e) or (ch = i) or (ch = o) or (ch = u) then...
if ch in [a, e, i, o, u] then....
, :
type
days = set of 1..31;
digc = set of 0.. 9;
error = set of 1..24;
const
workDays: days = [1..5, 8..12, 15..19, 22..26, 29,30];
evendigits: digc = [0, 2, 4, 6, 8];
err: error = [ ];
. , . : 1 . 256 32 . . , .