(. .4.1) , , , -. ORD(X), X. ORD(X) X, .. ORD(X) = X X, . ORD(X) , 0 1 ( ), 0 155 (), 0 65535 (). - , ORD(X) .
:
PRED (X) - (, ORD(X)- 1), ..
ORD(PRED(X)) = ORD(X) - 1;
SUCC (X) - , ORD(X) +1, ..
ORD(SUCC(X)) = ORD(X) + 1.
,
var
: Char;
begin
:= '5';
end.
PRED(C) '4', SUCC(C) - '6'.
, , PRED(X) , a SUCC(X) - .
. , , . . 4.1 , .
4.1
, | ||
Byte | 0...255 | |
ShortInt | -128...+127 | |
Word | 0...65535 | |
Integer | -32768...+32767 | |
LongInt | -2 147 483 648... +2 147 483 647 |
, .. , WORD, BYTE ( ), LONGINT INTEGER, , , SHORTINT.
, , .4.2. b, s, w, i, l BYTE, SHORTINT, WORD, INTEGER LONGINT, x - ; vb, vs, vw, vi, vl, vx . .
4.2
, | ||
abs (x) | x | |
chr(b) | Char | |
dec (vx[, i]) | - | vx i, i - 1 |
inc(vx[, i]) | - | vx i, i - 1 |
Hi(i) | Byte | |
Hi(w) | To | |
Lo(i) | " | |
Lo (w) | " | |
odd(l) | Boolean | True, - |
Random (w) | , 0...(w-l) | |
sgr (x) | X | |
swap (i) | Integer | |
swap (w) | Word |
, , - , ( ). , , :
|
|
var
: Integer;
, : Real;
begin
:= 32767; { INTEGER}
:= + 2; { !}
:= LongInt()+2; { }
WriteLn(x:10:0, :10:0)
end.
-32767 32769
. FALSE () TRUE (). :
ord(False) = 0;
ord(True) = 1;
False < True;
succ(False)= True;
pred(True) = False.
, , :
var
1: Boolean;
begin
for 1:= False to True do....
. . 0...255. , ORD.
ASCII (American Standard Code for Information Interchange - ). 7- , .. 128 0 127. 8- , , 0 255. 0...127 ASCII (. 4.3). 128...255 ( .2 ).
4.3
ASCII | |||||||
NUL | BL | ' | |||||
! | A | a | |||||
STX | " | b | |||||
# | |||||||
EOT | $ | D | d | ||||
ENQ | % | E | e | ||||
& | F | f | |||||
BEL | ' | G | g | ||||
BS | ( | H | h | ||||
) | I | i | |||||
LF | * | J | j | ||||
VT | + | k | k | ||||
FF | , | L | i | ||||
CR | - | M | m | ||||
SO | . | N | n | ||||
SI | / | ||||||
DEL | p | P | |||||
DC1 | Q | q | |||||
DC2 | R | r | |||||
DC3 | S | s | |||||
DC4 | T | t | |||||
NAK | U | u | |||||
SYN | V | V | |||||
ETB | w | w | |||||
CAN | X | X | |||||
EM | |||||||
SUB | : | z | z | ||||
ESC | / | [ | { | ||||
FS | < | \ | l | ||||
GS | = | ] | } | ||||
RS | > | ^ | ~ | ||||
US | ? | n |
0...31 . , . - :
|
|
BEL | ; | |
; , 8, 1 (9, 17, 25 ..) | ||
LF | ; , , | |
VT | ; | |
FF | ; , | |
CR | ; Enter ( READ READLN ; ) | |
SUB | ; Ctrl-Z; | |
SSC | ; ESC; |
CHAR , : R() - CHAR; BYTE ;
UPCASE(CH) - CHAR; , - , , :
var
cl,c2: Char;
begin
cl:= UpCase('s');
c2:= UpCase ('');
WriteLn(cl,' ',c2)
end.
UPCASE ,
S
. , . , , :
typ
colors =(red, white, blue);
. , , , , :
type
=(,,,,,,,,,,,);
var
: ;
begin
.......
if = then WriteLn(' !');
.......
end.
, , . ! , :
type
TypeMonth=(jan,feb,mar,may,jun,jul,aug,sep,oct,nov,dec);
var
month: TypeMonth;
begin
.......
if month = aug then WriteLn(' !');
.......
end.
: 0, - 1 .. 65536 , WORD , 1 ..
|
|
, . , , :
type
colors = (black, red, white);
ordenal= (one, two, three);
days = (monday, tuesday, Wednesday);
:
ord(black)=0,..., ord(white)=2,
ord(one)=0,...ord(three)=2,
ord(monday)=0,...ord(Wednesday)=2.
,
var
col:colors; num:ordenal;
day: days;
col:= black;
num:= succ(two);
day:= pred(tuesday);
col:= one;
day:= black;
, , ORD(X). : WORD , 1 . (. . 4.4). , :
col:= one;
col:= colors(0);
,
col:= 0;
.
, :
var
col: (black, white, green);
-. - , , -. - :
<..>..<..>
<.. > - -;
<..> - .
:
type
digit = '0'..'9';
dig2= 48..57;
- TYPE, , :
var
date: 1..31;
month: 1..12;
Ichr: 'A'..'Z';.
- :
- .. , ;
- . - , , . ,
type
days = (mo,tu,we,th,fr,sa,su);
WeekEnd = sa.. su;
var
w: WeekEnd;
begin
.....
w:= sa;
.....
end;
ORD(W) 5, PRED(W) .
, -:
IG() - -, X;
LOW(X) - -.
-32768...32767
var
k: Integer;
begin
WriteLn(Low(k),'..',High(k))
end.
39.
, , , . , , , , , . , .
|
|
, , . , :
:
(-1)s × M × BE, s , B-, E , M .
. , B=2 ( ) , 2 , , 10. B=2, :
(-1)s × M × 2E
? , . (|M|=3). , , 5, 1012. 22=4, ( ) 21=2, 20=1. () . E=2. , 1.01e+2. , , .
, 3 . , , , E=1.
1.01e+1 = 1×21+0×20+1×2-1=2+0,5=2,5
, -. |M|=4. 2 :
2 = 10 ( ) = 1.000e+1 = 0.100e+2 = 0.010e+3.
, .
( ) . 2 (1.000e+1), 000, .. . .
, :
(-1)s × 1.M × 2E.
. .