.


:




:

































 

 

 

 


. .




11

 

 

Turbo Pascal

:

Turbo Pascal.

 

. . ( ) 0 255. , .

 

:

 

1- :

Type

= string [ ];

Var

: ;

 

2- :

Var

: string [ ];

 

, , 255 .


 

:

Type

Stroka:string[50];

Var

St:Stroka;

St1:string;

St2:string[25];

:

onst

St:string= !;

 

 

, , . , , . .

 

(+) .

:

 

'E'+'C'+' 18' +'40' 'EC 1840'

 

255.

 

(=, <>, <, >, >=, <=) , , .. , , . , , . True, , False, .


 

:

 

'COSM1'<'COSM2' True

 

, , , , . , .

(:=).

. , , .

.

 

 

Delete (St, Poz, N) N St, Poz.

 

St
'' Delete (Str, 4, 2) ''

 

Insert (Str1, Str2, Poz) Str1 Str2, Poz.

 

:

Var S1, S2, S3: string[11];

...

S1:=' EC ';

S2:='1841';

S3:=Insert (S1, S2, 4);

S3 ' 1841'.

 

Str (I, St) I ( ) St. I , . , .

 

I
  Str (I:6, St) ' 1500'

 

4) Val (St, I, Cod) St I. St . Cod . , Cod , (, ), Cod , I .

 

St
'1450' Val (St, I, Cod) 1450 Cod=0

 

 

Copy (St, Poz, N) St N , Poz.

 

St
'ABCDEFG' Copy (St, 2, 3) 'BCD'

 

Concat (Str1, Str2,..., StrN) Str1, Str2,..., StrN , .

 

Concat ('AA', 'XX', 'Y') 'AAXXY'

 

Length (St) St.

 

St
'123456789' Length (St)  

 

Pos (Str1, Str2) Str2 Str1. , Str1. Str2 Str1 , 0.

 

Str1
'abcdef' Pos('de', Str1)  
'abcdef' Pos('r', Str1)  

 

:

. .

program sorta;

type

indata=string[80];

mas=array[1..80] of indata;

var

st:mas;

i,n:integer;

Procedure sortstring(var inm:mas; n:integer);

Procedure insort(L,R:integer;var M:mas);

var

a,b:indata;

i,j:integer;

begin

i:=L;

j:=R;

a:=m[(l+r)div 2];

repeat

while m[i]<a do i:=i+1;

while A<m[j] do j:=j-1;

if i<=j then

begin

b:=m[i]; m[i]:=m[j];

m[j]:=b; i:=i+1; j:=j-1;

end;

until i>j;

if l<j then insort(l,j,m);

if l<r then insort(i,r,m);

end;

begin

insort (1,n,inm);

end;

begin

writeln (' ');

readln (n);

writeln (' ');

for i:=1 to n do

readln (st[i]);

Writeln (' :');

for i:=1 to n do

writeln (st[i]);

sortstring(st,n);

Writeln (' ');

for i:=1 to n do

writeln (st[i]);

end.





:


: 2016-12-04; !; : 958 |


:

:

, , .
==> ...

1708 - | 1379 -


© 2015-2024 lektsii.org - -

: 0.02 .