Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program lab7;
- {$APPTYPE CONSOLE}
- uses crt;
- type
- Rec1=Record
- tema:string;
- num:integer;
- raz:string;
- zap:integer;
- next1:^Rec1;
- end;
- Rec4=Record
- raz:string;
- zap:integer;
- next4:^Rec4;
- end;
- Rec3=Record
- num:integer;
- next3:^Rec3;
- next4:^Rec4;
- end;
- Rec2=Record
- tema:string;
- next2:^Rec2;
- next3:^Rec3;
- end;
- var
- tmpM, HeadM: ^Rec1;
- tmpT, HeadT: ^Rec2;
- tmpN, HeadN,tmpk: ^Rec3;
- tmp1: ^Rec4;
- z, numN, zapN, K, L, I, J, count: integer;
- temaN, temaP, razN: string;
- mas: array [1..100] of integer;
- function check1(temaN:string):boolean;
- begin
- tmpT:=HeadT;
- check1:=False;
- while tmpT<>nil do
- begin
- if tmpT^.tema = temaN then
- begin
- check1:=True;
- exit;
- end;
- tmpT:=tmpT^.next2;
- end;
- end;
- function check2(numP:integer):boolean;
- begin
- tmpN:=HeadN;
- check2:=False;
- while tmpN<>nil do
- begin
- if tmpN^.num = numP then
- begin
- check2:=True;
- exit;
- end;
- tmpN:=tmpN^.next3;
- end;
- end;
- procedure SHOW3();
- begin
- tmpM:=HeadM;
- while tmpM<>nil do
- begin
- if tmpM^.zap > 10 then
- begin
- writeln('| ' ,tmpM^.tema:14, ' | ',tmpM^.num:8, ' | ', tmpM^.raz:14, ' | ',tmpM^.zap:8, ' |');
- writeln( '|-------------------------------------------------------|');
- end;
- tmpM:= tmpM^.next1;
- end;
- end;
- procedure SHOW4(temaP:string);
- begin
- tmpM:=HeadM;
- while tmpM<>nil do
- begin
- if tmpM^.tema = temaP then
- begin
- writeln('| ' ,tmpM^.tema:14, ' | ',tmpM^.num:8, ' | ', tmpM^.raz:14, ' | ',tmpM^.zap:8, ' |');
- writeln( '|-------------------------------------------------------|');
- end;
- tmpM:= tmpM^.next1;
- end;
- end;
- procedure NEWW(temaN,razN:string;numN,zapN:integer);
- begin
- new(tmpM);
- tmpM^.next1:= HeadM;
- HeadM:= tmpM;
- tmpM^.tema:= temaN;
- tmpM^.num:= numN;
- tmpM^.raz:= razN;
- tmpM^.zap:= zapN;
- if check1(temaN) then
- begin
- tmpT:= HeadT;
- while tmpT^.tema <> temaN do
- begin
- tmpT:=tmpT^.next2;
- end;
- if check2(numN) then
- begin
- tmpN:=HeadN;
- while tmpN^.num <> numN do
- begin
- tmpN:=tmpN^.next3;
- end;
- new(tmp1);
- tmp1^.next4:=tmpN^.next4;
- tmpN^.next4:=tmp1;
- tmp1^.raz:= razN;
- tmp1^.zap:= zapN;
- end
- else
- begin
- new(tmpN);
- tmpN^.next3:= HeadN;
- HeadN:= tmpN;
- tmpN^.num:= numN;
- new(tmp1);
- tmp1^.next4:=tmpN^.next4;
- tmpN^.next4:=tmp1;
- tmp1^.raz:= razN;
- tmp1^.zap:= zapN;
- end;
- end
- else
- begin
- new(tmpT);
- tmpT^.next2:= HeadT;
- HeadT:= tmpT;
- tmpT^.tema:= temaN;
- new(tmpk);
- tmpk^.next3:=tmpT^.next3;
- tmpT^.next3:=tmpk;
- tmpk^.num:= numN;
- new(tmp1);
- tmp1^.next4:=tmpk^.next4;
- tmpk^.next4:=tmp1;
- tmp1^.raz:= razN;
- tmp1^.zap:= zapN;
- end;
- end;
- procedure Numb ();
- begin
- count := 0;
- tmpM := HeadM;
- while tmpM <> nil do
- begin
- inc(count);
- tmpM := tmpM^.next1;
- end;
- end;
- //////////////////////////////////////////////
- begin
- HeadM := nil;
- HeadT := nil;
- HeadN := nil;
- while true do
- begin
- textcolor(10);
- writeln('');
- writeln('******************** МЕНЮ ********************');
- writeln('|--------------------------------------------|');
- write('| '); textcolor(13); write('Выберите: '); textcolor(10); writeln('|');
- write('| '); textcolor(13); write('0. Завершение работы '); textcolor(10); writeln('|');
- write('| '); textcolor(13); write('1. Добавление сведений '); textcolor(10); writeln('|');
- write('| '); textcolor(13); write('2. Просмотр разделов с числом записей > 10 '); textcolor(10); writeln('|');
- write('| '); textcolor(13); write('3. Просмотр всей таблицы '); textcolor(10); writeln('|');
- write('| '); textcolor(13); write('4. Просмотр темы '); textcolor(10); writeln('|');
- write('| '); textcolor(13); write('5. Вывод отсортированной таблицы '); textcolor(10); writeln('|');
- writeln('|--------------------------------------------|');
- writeln('**********************************************');
- write('Ваш выбор: ');
- textcolor(15);
- readln(z);
- textcolor(10);
- if z = 0 then
- exit;
- if z = 2 then
- begin
- writeln('|-------------------------------------------------------|');
- write('|');
- textcolor(13);
- write('Формат:| тема | номер раздела | раздел | число записей'); textcolor(10); writeln(' |');
- writeln('|-------------------------------------------------------|');
- writeln('************************ ТАБЛИЦА ************************');
- SHOW3();
- writeln('*********************************************************');
- end;
- if z = 3 then
- begin
- tmpM:=HeadM;
- writeln('|-------------------------------------------------------|');
- write('|');
- textcolor(13);
- write('Формат:| тема | номер раздела | раздел | число записей'); textcolor(10); writeln(' |');
- writeln('|-------------------------------------------------------|');
- writeln('************************ ТАБЛИЦА ************************');
- while tmpM<>nil do
- begin
- writeln('| ' ,tmpM^.tema:14, ' | ',tmpM^.num:8, ' | ', tmpM^.raz:14, ' | ',tmpM^.zap:8, ' |');
- writeln( '|-------------------------------------------------------|');
- tmpM:= tmpM^.next1;
- end;
- writeln('*********************************************************');
- end;
- if z = 4 then
- begin
- write('Введите название темы: ');
- textcolor(15);
- readln (temaP);
- textcolor(10);
- writeln('|-------------------------------------------------------|');
- write('|');
- textcolor(13);
- write('Формат:| тема | номер раздела | раздел | число записей'); textcolor(10); writeln(' |');
- writeln('|-------------------------------------------------------|');
- writeln('************************ ТАБЛИЦА ************************');
- SHOW4(temaP);
- writeln('*********************************************************');
- end;
- if z = 5 then
- begin
- writeln('|-------------------------------------------------------|');
- write('|');
- textcolor(13);
- write('Формат:| тема | номер раздела | раздел | число записей'); textcolor(10); writeln(' |');
- writeln('|-------------------------------------------------------|');
- writeln('************************ ТАБЛИЦА ************************');
- Numb();
- tmpM := HeadM;
- i := 1;
- while tmpM <> nil do
- begin
- mas[i] := tmpM^.zap;
- tmpM := tmpM^.next1;
- inc(i);
- end;
- K := 1;
- for I
- := 1 to count - 1 do
- begin
- K:= I;
- for J := I + 1 to count do
- if mas[J] < mas[K] then K := J;
- L:=mas[I];
- mas[I] := mas[K];
- mas[K] := L;
- end;
- for i := 1 to count do
- begin
- tmpM:=HeadM;
- while tmpM<>nil do
- begin
- if tmpM^.zap = mas[i] then
- begin
- writeln('| ' ,tmpM^.tema:14, ' | ',tmpM^.num:8, ' | ', tmpM^.raz:14, ' | ',tmpM^.zap:8, ' |');
- writeln( '|-------------------------------------------------------|');
- break;
- end;
- tmpM:= tmpM^.next1;
- end;
- end;
- writeln('*********************************************************');
- end;
- if z = 1 then
- begin
- textcolor(10);
- writeln('**********************************************');
- write('|'); textcolor(13); write('Название темы: '); textcolor(10); write('|');
- textcolor(15);
- readln(temaN);
- textcolor(10);
- write('|'); textcolor(13); write('Номер раздела: '); textcolor(10); write('|');
- textcolor(15);
- readln(numN);
- textcolor(10);
- write('|'); textcolor(13); write('Название раздела: '); textcolor(10); write('|');
- textcolor(15);
- readln(razN);
- textcolor(10);
- write('|'); textcolor(13); write('Число записей в разделе: '); textcolor(10); write('|');
- textcolor(15);
- readln(zapN);
- textcolor(10);
- writeln('**********************************************');
- NEWW(temaN,razN,numN,zapN);
- end;
- writeln('');
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement