close

Вход

Забыли?

вход по аккаунту

?

Моя записка

код для вставкиСкачать
??????????
1 ?????? ?1.46_______________________________________________3
1.1. ?????????? ?????? ? ?? ??????________________________
1.2. ???????? ???????? ??????___________________________
1.3. ?????????????? ?????????__________________________
1.4. ?????????? ????????????_____________________________
1.5. ??????????_______________________________________
2 ?????? ?2.20____________________________________________11
2.1. ?????????? ?????? ? ?? ??????________________________
2.2. ???????? ???????? ??????___________________________
2.3. ?????????????? ?????????__________________________
2.4. ?????????? ????????????_____________________________
3 ?????? ?3.13______________________________________________14
3.1. ?????????? ?????? ? ?? ??????________________________
3.2. ???????? ???????? ??????___________________________
3.3. ?????????????? ?????????__________________________
3.4. ?????????? ????????????_____________________________
4 ?????? ?4.7_______________________________________________19
4.1. ?????????? ?????? ? ?? ??????________________________
4.2. ???????? ?????????_________________________________
4.3. ?????????????? ?????????__________________________
4.4. ?????????? ????????????____________________________
?????? ?????????????? ??????????_______________________22
1 ?????? ?1.46
1.1 ?????????? ?????? ? ?? ??????
??????? : ???????? ?????? ??????? ???????? ???????????? ?????? ????????? ? ?????????? ? ????? ????????????? ???????? ??????? ????????. ?????? ?? ????? ???????? ????? ???????????. ????????? ?????? ???????? ????????? ????????????? ???????? ?? ?????????? ?????? ????????. ???????? ?? ??????? ??????????? ??????????????. ??????? ???????? ??????, ? ????? ????? ????????? ??? ??????? ???????????? ??????. 1.2 ???????? ???????? ??????
???????? ???????????? ?????????, ???????? ??????:
type
type_info = record {???????? ?????? ? ?????????}
num:string [6];{????? ????????} dolg:string;{ ????}
end;
type_ukaz = ^type_elem;{???????? ????????? ?? ??????? ????????? ??????}
type_elem = record {??? ?????????}
info: type_info;{???? ? ??????? ? ?????? ?????????}
ukaz: type_ukaz;{????????? ?? ????????? ??-?}
end;
var
beg_spis, st, sp: type_ukaz;{????????? ??: ?????? ??????, ??????? ?????????, ?????????}
1.3 ?????????????? ?????????
??? ??????? ???????????? ??????, ??? ??????????? ????????? ????????: Input_in_spis (?????????, ??????? ?????? ?????? ?? ????? ? ???????? ??????), Output_from_spis (?????????, ??????? ??????? ?????? ?? ?????), Poisk_and_output (?????????, ??????? ????????? ????? ????????).
?????? ????????? ??? ?????? ??????? ?? ?????. ???????????? ????????? ? ????? ?????????? ? ?????????.
??? ???????? ?????? ??????????? ????????? Input_in_spis.
procedure Input_in_spis;
var
f_input: text;
i: byte;
fn: string;
begin
clearmem;
repeat
write('??????? ??? ???? ??????: ');
readln(fn);
if not FileExists(fn) then
writeln('?????? ?????. ?????????? ??? ???');
until FileExists(fn);
assign(f_input,fn);
reset(f_input);
new(st);
beg_spis:= st;
while not eof(f_input) do
begin
with st^.info do
begin
readln(f_input,num);
readln(f_input,dolg);
end;
sp:= st;
new(st);
sp^.ukaz:= st;
end;
sp^.ukaz:= nil;
close(f_input);
end; ????? ????????? ?????? ????? ??????? ?? ????? ??? ????? ?? ??????? ? ?????? ?????????? ? ??????????? ??? ????????.
{?????? ????????? ?????? ?? ?????}
procedure Output_from_spis;
var
i,k: byte;
label label3;
begin
clrscr;
writeln('??????? f1 ??? ????????? ????????? ??????');
writeln('|___________________________________________ |');
writeln('| ???? ????????? |');
writeln('|__________________________________________________|');
writeln('| | |');
writeln('| ????? ???????? | ???? |');
writeln('| | |');
writeln('|__________________________|__________________________|');
st:= beg_spis;
label3:
k:=0;
i:=1;
while st<>nil do
begin
y:=14;
with st^.info do
begin
writeln('| | |');
writeln('|__________________________________________________|');
gotoxy(1,wherey-2);write(i,' ',num);inc(i);
gotoxy(24,wherey);write(dolg);
gotoxy(1,wherey+2);
k:=k+1;
end;
st:= st^.ukaz;
if (k=11) then begin
Write('___________________________________________________________');
Writeln('?????? - f1');
while ReadKey <> #59 do
begin
end;
clrscr;
goto label3;
end;
end;
Write('________________________________________________________________________________');
Writeln('??????? - f1');
while ReadKey <> #59 do
begin
end;
clrscr;
begin chose; end;
end;
{-------------------------------------------------------------------}
{?????}
procedure POISK_AND_OUTPUT;
var poisk: string;
sum: integer;
flag: boolean;
begin
begin clrscr; end;
writeln('??????????,??????? ????? ??? ????????????? ????? ?????????????!');
read(poisk);
flag:= false;
st:= beg_spis;
sum:=0;
while st<>nil do
begin
with st^.info do
if ((num=poisk) or
(dolg=poisk)) then
begin
flag:= true;
Writeln('????? ????????:',num,' ','?????????????: ',dolg);
sum:=sum + StrToInt(dolg);
gotoxy(1,wherey+2);
end;
sp:= st;
st:= st^.ukaz;
end;
If st=nil then Writeln('???????? ????????????? ??????? ????????:',sum);
gotoxy(1,wherey+1);
if (flag = false) then
begin
gotoxy(1,wherey-1);
writeln('?????? ??????? ?? ???????? ?????????!');
end;
Writeln('??????? - f1');
while ReadKey <> #59 do
begin
end;
clrscr;
sum:=0;
begin chose; end;
end; 1.4 ?????????? ????????????
????????? ?????? ???????? ???????? ?? ??????? 1.
??????? 1 - ????? ????????
??? 1.
1.5 ??????????
? ?????? ?????? ??? ?? ???????????? ??????????? ?????????. ?? ?????????? ???????? ?????????????? ?????????, ????? ??? CHOSE, command ? ??????.
??? 2.
2 ?????? ?2.20
2.1 ?????????? ?????? ? ?? ??????
???????: ???????? ????? - ???????????? ?????. ??????? ????????? ??? ???????, ???????: a) ????????? ??????? ?????????????? ???? ????????? ?????; b) ??????? ?? ????? ???????? ?? ????????? ??????? ???????? ???????????????. ?????? ???????? ??????????????? ????????? ??? ???????? ????? ???????????? ?????.
????? ????? ????????? ??? ????????? ?????????? ? ????? ? ????.
? ? ?????????? ????? ????????? ??? ??????? ?????? ??????.
2.2 ???????? ???????? ??????
??? ?????????? ?????? ????????? ?????????? ???????????? ????, ??????? ????????? ?????????:
type stack=^st;
st=record;
data: real;
next:stack;
end;
????????? ???????? ?????????????? ???? data(?????? ???????????? ?????), ? ????? ???? next- ????????? ?? ????????? ??????? ?????.
2.3 ?????????????? ?????????
? ???????? ????????? ??????? ??????? ????????? ????????? ?????? ? ????:
procedure create_stack(var u: stack; el: real);
var x: stack;
begin
new(x);
x^.data:=el;
x^.next:=u;
u:=x;
end;
????? ???????? ??? ????????? ??? ??????? ?????? ??????:
procedure arifm_stack(u:stack);
begin
k:=0;
sum:=0;
kol:=0;
while u<>nil do
begin
inc(k);
kol:=kol+1;
sum:=sum+u^.data;
u:=u^.next;
end;
c:=sum/kol;
writeln('???????????????????? ?????:',c:3:3);
end;
procedure itog;
Begin
while stack1<>nil do
begin
p:=stack1;
if stack1^.data>=c then
create_stack(u,p^.data);
stack1:=stack1^.next;
delete(p);
end;
end;
? ?? ?????? ??????? ???? ?????????? ???? ????????, ? ??? ??? ??????? ????????? print_stack:
procedure print_stack(u:stack);
begin
k:=0;
while u<>nil do
begin
inc(k);
writeln ('-->',u^.data);
u:=u^.next;
end;
end;
2.4 ?????????? ????????????
?? ??????? 3 ?????????? ??? ??????? ??????
??? 3.
3 ?????? ?3.13
3.1 ?????????? ?????? ? ?? ??????
???????: ??????? ???-?????? - ???????????? ?????. ??????? ????????? ??? ???????, ???????: a) ????????? ??????? ?????????????? ???? ?????? ??????; b) ????????? ? ?????? ??????? ?? ?????????, ??????????? ? ?????????? ????????? (???????). ??? ??????? ?????? ?????? ?????????? ??????????? ????????? ?????????? ????????? ??????, ?? ??????? ? ???????, ? ????????? ??? ???????? ???????? ??????????????? ??????. 3.2 ???????? ???????? ??????
? ?????? ????????? ?????????? ??????????? ??? ??????. ???????? ??? ????????? ???????????? ????:
type PTree = ^AVLTree;
AVLTree = record
balancefactor:shortint;
key:real;
left,right:PTree;
end; ????????? ???????? ?????????????? ???? key, ? ????? ???? left ? right - ????? ?????? ???????. ??? ???????? ??????? ????? ?????????????? ???? ???????? ?????? ??????.
3.3 ?????????????? ?????????
??? ??????? ???????????? ?????? ?????????? ????????? ????????? : AVLInsert, Sredn, graphOUT.
?????????? ???? ?? ????????.
AVLInsert -?????????? ???????? ? ??????.
procedure AVLInsert(var Tree:PTree;x:real;var need_balance:boolean);
var
need_balance_cur:boolean; begin
need_balance_cur:=false;
if Tree=nil then
begin
Tree:=NewNode(x);
need_balance:=true;
end
else
if x<Tree^.key then begin
AVLInsert(Tree^.left,x,need_balance_cur);
if need_balance_cur then
begin
if (tree^.balanceFactor = leftheavy) then // ???? ???????? ????? ?? ???? ??? ??????????????? ?????
UpdateLeftTree(tree, need_balance) // ????????? ????????????????
else if (tree^.balanceFactor = balanced) then //???? ???????? ????? ?? ???????????????? ????
begin
tree^.balanceFactor := leftheavy; //?????? ?????? ??????? ???? ?????
need_balance := true; // ?????? ?? ??????? ???? ???????? ????????? ???????????????? end
else // ???? ??????? ????? ???? ?????, ? ??? ????? ? ???????? ???? ??? ??????? ??????, ??????? ???? ???? ????????????????
begin
tree^.balanceFactor := balanced;
need_balance :=false;
end;
end
else
// ???????????????? ?? ?????????. ?? ?????????? ?????????? ????
need_balance := false;
end
else
if x>Tree^.key then
begin
AVLInsert(Tree^.right,x,need_balance_cur);
if need_balance_cur then
begin
if (tree^.balanceFactor = rightheavy) then // ???? ???????? ?????? ?? ???? ??? ??????????????? ??????
UpdateRightTree(tree, need_balance) // ????????? ????????????????
else if (tree^.balanceFactor = balanced) then //???? ???????? ?????? ?? ???????????????? ????
begin
tree^.balanceFactor := rightheavy; //?????? ?????? ??????? ???? ?????
need_balance := true; // ?????? ?? ??????? ???? ???????? ????????? ???????????????? end
else // ???? ??????? ????? ???? ??????, ? ??? ????? ? ???????? ???? ??? ??????? ?????, ??????? ???? ???? ????????????????
begin
tree^.balanceFactor := balanced;
need_balance :=false;
end;
end
else
// ???????????????? ?? ?????????. ?? ?????????? ?????????? ????
need_balance := false;
end;
end; 3.4 ?????????? ????????????
??????? ???????????? ?????? ?????????? ????????? ??????, ????? ???? ????????. ?????? ????????? ??????????? ?????????? ???????? ??????????????? ? ?????????? ??? ? ?????? ??????? ?? ??????? 4.
??? 4.
4 ?????? 4.7
4.1 ?????????? ?????? ? ?? ??????
???????: ???????????? ?????????? ???????. 4.2 ???????? ?????????
???? ?????????? ??????????? ? ?????????: ?????????? ????????? ???????? ????????? ??? h. ??????????????? ??????????????? ?????????? , r=0, z=h ??? ??????? ???????.
??????????? ????????? ? ????? ????????? ??? ???? i, ?????, ??? 0<=i<N-z ? i&h=r, ? ????? i+1 ? i+z+1.
? ????? ??????? z - ????????, ??????? h, ?? ???? z/h - ???????? ?????, ? h - ??????? ??????, ????????????? i&h<>(i+z)&h, ??????, ????????? ? ????? ????? ????????? ??? ???? ?????? ????????? i ? ????? ??????? ??? ???? ????????????. ? ????? ? ???? ?????????? ? ??????? ????????????.
????? ?????????? ???????? ??????????????? ?????????? z=q-h, q=q/2, r=h ? ??????? ????????????, ???? q>=h.
? ????? ??????? ???????? ?????? ????? ?????????? ? ????? h.
????? h ??????????? ? ??? ???? h=h/2 (? ?????? ?????? ????) ? ??????? ????????????, ???? h>0.
?????????? ?????? ???????? ?????????? ?? ??????? ??????????? ???????.
4.3 ?????????????? ?????????
????????? ?????? ?????? ????????? ???????: ??? ?????????? ?????? ????????? ??????? ???? ? (Pelles C). ?????? ????? ????? 16 ????????, ?????? ?? ??????? ????? ?????????? ????????. ?????????? ??????? ??????????:
void BatcherSort() // ??????????
{
unsigned p = N;
while (p > 0)
{
unsigned q = N, r = 0, d = p;
int b;
do
{
unsigned nTo = N - d;
for (unsigned i = 0; i < nTo; i++)
if ((i & p) == r)
{
if (Arr[i] > Arr[i + d])
{
int temp = Arr[i];
Arr[i] = Arr[i + d];
Arr[i + d] = temp;
}
}
b = q != p;
if (b)
{
d = q - p;
q >>= 1;
r = p;
}
}
while (b);
p >>= 1;
}
} 4.4 ?????????? ????????????
????????? ???????????? - ??????? 5.
??? 5.
?????? ?????????????? ??????????
1. ????. ????????? ????????????????. ??? 3.
2. ?????? ?. ?. ???????????????? ? ??????????, 2004
2
Документ
Категория
Без категории
Просмотров
8
Размер файла
262 Кб
Теги
записка
1/--страниц
Пожаловаться на содержимое документа