4
:
- ;
- , ;
- .
1.
, . . . :
1) ;
2) , ;
3) , .
, , , . , .
. . ( , ) , , , , .
, , , , , , , . , , , .. , .
, , , . :
type < > = < >;
:
var < >: < >;
, , , .. , . ,
const f1: boolean = true;
a: real = pi/180;
. , , , , , .
.
2. .
( ) , 1 . 28=256 0 1. . , ASCII (American Standard Code Information Interchange). ( 0..127) IBM- . , 0 9 48 57, 65 90, 97 122. ASCII , .
|
|
Char ( character ). ,
var c1, c2: char;
char .
:
1) , , c1:=g; c2:=n;
2) (#) ASCII, , c1:=#103; c2:=#110.
, :
Chr (x:byte): char ASCII;
Ord(x):longint , ;
Pred(x) , ;
Succ(x) .
Upcase(x:char): , .
Chr Ord :
hr (rd(x))=x;
Ord (hr(x))=i;
Chr (rd(x)-1)=Pred(x);
Chr (rd(x)+1)=Succ(x).
, . : , .
-, case.
, ASCII , 32 . , . - . , Esc, 27 ASCII Escape, HT , 9. :
1. ASCII-;
2. Ctrl-, .. , Ctrl - ; , Ctrl+H ( ^H);
3. Chr(i).
,
1. ch:=10; ch:=^J; ch:=chr(10)
ch , ( LF).
, :
|
|
var x, y, z: real; operator: char;
begin
writeln ( =); readln(x);
writeln ( +, -, *, /?); readln(operator);
writeln ( y=); readln(y);
case operator of
+: z:= x+y;
-: z:= x-y;
*: z:=x*y;
/: z:=x/y;
end;
writeln (z=,z); readln
end.
:
var ch:char; k,m:byte;
begin
readln(ch); k:=0;
repeat
m:=Ord(ch) Ord(0);
k:=10*k+m; readln(ch)
until not ((ch>=0) and (ch<=9));
writeln( k=,k); readln
end.
. , .
3. .
array[1..n] of char. string.
, var st1:string;
st2:string[8];
. st2 8. , st1, 255.
, , . , , st2:=frequency. 8, st2 frequenc.
, , . , st2[0], .
char, , ASCII . , , , .
, string char , char .
Length(st2) Ord(st2[0]). Length , .
=, <, <= .. , . , . . , 150 < 160; Max< mini.
. , . ,
const s1:string[50]=;
string[50], 4.
, st2[i]. , , , , . , .
4. .
.
1. , str , :
Length(str:string):byte.
2. Pos(substr, str:string):byte substr str. byte, , substr str. , 0.
|
|
,
st1:=First; st2:=SetFirst; k1:=Pos(st1,st2);
k1 4.
3. (). , :
st:=st1+st2++stn;
st:=Concat(st1,st2,,stn).
st 255 .
4. Copy(str:string, kstart,m:integer): string m str, kstart . . ,
gamma:= SetColor; beta:=Copy(gamma, 4,5); writeln(beta);
beta=Color.
5. Delete (var str:string, kstart, m:integer) m str, ksatr. ,
alfa:=element;
Delete (alfa,4,3);
alfa=elet. m , .
6. Insert(instr:string, var str:string, kstart:integer) instr str, kstart. ,
beta:=123 ; alfa:=element;
Insert(beta, alfa,5);
alfa=123_element. Delete Insert kstart , , 255.
7. Str(n [:width[:decimals]]; var strn:string) n strn. n , strn , n.
, Str(4.52, st1) st1=4.52.
8. Val (strn:sting; var n; var errcode:integer) , strn n. errcode . strn , , errcode . ,
Val(12345, n,k);
n = 12345; k=0.
Val (12_45 n, k);
k=3.
1. . .
var str:string; k:integer;
begin
writeln( ); readln(str);
for k:=1 to Length(str) do
if Copy(str,k,1)=.
then begin Insert( ,str,k+1); str[k+2]:= UpCase(str[k+2] end;
writeln(str); readln
end.
. , .
2. . .
var i: integer; s: string;
Begin
writeln ( ); readln (s);
i:=1;
while i<Length(s) do begin
if (s[i]=,) and not (s[i+1]= )
then Insert( ,s,i+1); Inc (i)
end;
writeln(s);
End.
While, For? Pos( , s)? , , . !, ? , . .
|
|
3. , .
type strtype = string[20];
var strread,strrev:strtype;
function Reverse(str:strtype):strtype;
var firstch:char; rrest:strtype;
begin
if Length(str)=1
then Reverse:=str
else begin
firstch:=str[1]; Delete(str,1,1);
rrest:=Reverse(str);
Reverse:=Concat(rrest,firstch)
end
end;
Begin
repeat
writeln('Input text.Word endf - end'); readln(strread);
strrev:=Reverse(strread); writeln(strrev)
until strread = 'endf';
readln
End.
. - (), : , , ..
, . : , , , , .
, .
var x,y,z:string; k:integer;
function UpRusCase(w:char):char;
{ }
begin
if (w>=) and (w<= )
then UpRusCase:=Chr(Ord(w)+32)
UpRusCase:=w
end;
Begin
y:= ; z:= ;
writeln( ); readln(x);
for k:=1 to Length(x) do
if (Copy(x,k,1)>=) and (Copy(x,k,1)<=)
then begin z:=Concat(z,UpRusCase(Copy(x,k,1)));
y:=Concat(UpRusCase(Copy(x,k,1)),y)
end;
if y=z
then writeln(, )
else writeln(, );
readln
End.
.
4. . . , , . , . . .
const n=20; m=10; { }
type Tstring=string[m];
var a: array[1..n] of Tstring; s: string; k, i: Integer;
procedure DelPr (var s: string); { }
begin
while (s[1]= ) and (s<> ) do Delete (s,1,1)
end;
function GetWord (var s: string): Tstring;
{ , }
begin
GetWord:=Copy(s,1,Pos( ,s)-1);
Delete (s,1,Pos( ,s));
DelPr(s)
end;
Begin
writeln ( ); readln (s);
s:=s + ; { . ?}
DelPr(s); { }
k:=0;
while s<> do begin { }
Inc(k); a[k]:=GetWord(s) { }
end;
for i:=1 to k do writeln (A[i]); readln
End.
DelPr(s) , GetWord . ? ? , ? DelPr
while (s[1]= ) and (s<> ) do Delete (s,1,1)
while (s[1]= ) do Delete (s,1,1)
, . .
5. Y. r Y , Y . , Y , . , . = 'abcd', Y= 'dxxc', r= 4, = '1111111', Y= '111222', r= 7. :
var i,j,r: integer; s,x,y: string;
Begin
writeln (' '); readln (x);
writeln (' '); readln (y);
if Length(x)>Length(y)
then begin s:=x; x:=y; y:=s end;
{ Y X }
r:=Length(y);
for i:=l to Length (x) do begin
j:=1;
while (j<=Length(y)) and (y[j]<>x[i)) do Inc(j);
if j>Length(y)
then Inc(r)
else begin dec(r); Delete(y,j,1) end
{ . Y }
end;
writeln (' ', r); readln
End.
Y ? . Delete(Y,j,l). ? , , () .
|
|