1 , . , , . . . , .
) 10.3.
var a;set of byte;
k,x,n:byte; begin
randomize; a:=[]; k:=l;
write(' : '); readln(n);
while k<=n do begin
x:=random(n)+1;{ 1 n }
if not {x in a) then begin { ? }
write(x, ' '); :=+[]; { } k:=k-f-l, end;
end; readln; end.
255. .
, . , , , . . , . "" .
. , , - ( ) ( 10.4).
[ 10.4.
: ' -V \-.
var a:array[l..10000] of integer; k,l,i,n:integer;
ok:boolean; begin
randomize;
write(' : '); readln(n);
for k:=l to n do
a[k]:=k; { 1 n } for k:=l to n do begin
l:=random(k)+l; { } i:=a[k]; a[k]:=a[l]; a[l]:=i; { a[k] [1] } end;
writeln(' :'); for k:=l to n do write(a[k],' '}; readln; end.
. , . , , , . .
Turbo Pascal . , . . , , .
|
|
.
, , . , () . , ( , ). .
.
type
= record
!: !;
2: 2;
: ; end;
.
Var
: ;
:
type avto=record
number: integer; { }
marka: string[20]; { }
fio: string[40]; { , }
address: string[60]; { } end; var m,v: avto;
, . , avto :
. , . . , avto, :
m.number, .marka, .fio, m.address
, . .
:
m.number:=1964; m,marka:='Audi 100'; m.fio:= ' ..'; m.address:='y^. 53 .1 73';
/:
readln(m.number,m.marka,m. fio,m.address);
write(m.number:4,m.marka:lO.ra.fio:13,m.address:23);
/ ( ).
:
writeln(m) { }
, :
v .
. , , :
type person = record
fio: string[20];
age: 1..99;
prof: string[30]; end; var list:array [1.. 50] of person;
. Turbo Pascal with, :
with do ; { }
with, .
:
with m do
begin
number:=1964; marka:='Audi - 100';
address:='. 53 .1 73'; end;
. . , , - . , .
|
|
type complex=record
re:real; { } ira:real; { } end;
var a,b,c: complex; { a,b,c complex } begin
a.re:=6.8; a.im:=l.6;
, .
(, , ) (, , ). , Turbo Pascal .
. , : , , , , , .
pupil () , , 10 pupil ( 11.1).
[ 11.1.
type pupil = record { }
name: string[10]; { }
surname: string[20]; { }
school: integer; { }
class: byte; { }
end;
var school:array[1.,10]of pupil; n: 1.. 10; :byte;
procedure input_data;
{ } begin
writeln(' ', , ':');
write(' ?'); readln(school[n].name);
write (' ?'); readln(school[n].surname);
write (' ?'); readlnfschool[n].class);
writeln; end;
procedure write_data;
{ with } begin
with school[n] do begin
writeln(':',name); writeln(': ',surname); writeln(': ',school); writeln(': ',class);
end; end; begin { }
for n:=l to 10 do input_data;
writeln;
writeln(' 5 :');
writeln; n:=5; write_data;
writeln(' :')/writeln;
writeln{' :'); readln(c);
for n:=l to 10 do if school[n].classic then write_data;
readln;
. end.
"
, , . Turbo Pascal , . , , .
.
, . case... of . , , . case . , , .
, , , . , . , -, . . , . :
type
=1
case : of
!: (: ,...);
: (: ,...);
end; -,,
( ) . case end, . end . , .
|
|
:
, , , ;
, ;
, - , , : -
OopaN{);.
, , . : , .
. (book).
(author).
\ /
(title).
(year).
(publishinghouse).
(pages).
(article).
(author).
(title).
(year).
(journal).
(numberofjournal).
(begpagej).
(endpagej). (paper).
(author).
(title).
(year).
(numberofpaper).
(begpagerj).
(endpagerj).
: , , , ( 11.2).
! 11.2. ;
type
kind = (book,article,paper);
publi cat ion=re cord
{ }
autor,title: string;
year: word;
string; word); string; byte; word); byte; word); |
{ } case kindp: kind of
book: (publishinghouse pages
article: (journal numberofj ournal begpagej, endpagej paper: (numberofpaper begpagerj, endpagerj
end;
var pub: publication; j: word; begin
writeln(' '
repeat
write(' (0.. 2)='); readln(j); if j in [0..2] then with pub do begin Jcindp: = kind(j);
write{':'); readln(autor); write(':');readln(title); write(':'>;readln(year); case kindp of
book: begin
write(':'); readln(publishinghouse);
writef', .:'); readln(pages);
j end;
article: begin
write(' :'); readln{journal); write(':');readln(numberofjournal); write ':'); readln(begpagej, endpagej); end; paper: begin
write(' . :');readln(numberofpaper); write(':'); readln(begpagerj, endpagerj); end;
end; { case.. of } end; { with pub.. }
until not (j in [0..2]);( nd.
' *
, (. . 4). , : . . , , , . , / , , , . ( file , ).
|
|
, : , , . . . , . . , . , , " " . , , , .
, ( , , - . .) .
(, , . .) (. . 12. 1).
:
1. ,
.
,
.
2. (
). . ,
,
" ".
3. ().
. , ,
, .
( )
, . , . , , , . . , , . , , , , - . . , , "" "" , . , , .
, :
, , . , ;
, , , ;
, ;
.