Разработка программы «Киноафиши» на языке Turbo Pascal 7.1, страница 6

              temp:=top; window(1,12,80,25); show_tabl_up;

              while temp<>nil do

               begin

                  case poz_1 of

                 1: If temp^.x.dur=max then

                         begin show_elem(temp);k:=k+1; end;

                 2: If temp^.x.lim=max then

                 begin show_elem(temp); k:=k+1; end;

                 3: If temp^.x.rat=max then

                 begin show_elem(temp); k:=k+1; end;

                 end;

                 If k=5 then begin

                         show_tabl_down;

                         write(' push <Space> -look further'); readln;

                         clrscr; wherex; k:=0; show_tabl_up;

                       end;

                 temp:=temp^.y;

               end;

               show_tabl_down;

              end;

  end;

readkey; clrscr;

end;

procedure min_(top:p; poz_min:integer);

var temp:p; i,otv,k,min:real;

begin

  min:=99999;

  IF top=nil then begin window(1,10,20,15);writeln('  Table is empty!');end

          else

  begin

    temp:=top;

    while temp<>nil do

      begin

     case poz_2 of

      3: If temp^.x.dur<min     then min:=temp^.x.dur;

      2: If temp^.x.lim<min  then min:=temp^.x.lim;

      1: If temp^.x.rat<min    then min:=temp^.x.rat;

     end;

     temp:=temp^.y;

      end;

    window(1,12,39,25);

    writeln('Minimum = ',min:4:2); readkey;

    writeln('Would you like to see table?');

    write('(1-Yes/0-No) - '); readln(otv); clrscr;

    if otv=1 then begin

              temp:=top; window(1,12,80,25); show_tabl_up;

              while temp<>nil do

               begin

                 case poz_2 of

                 3: If temp^.x.dur=min then

                 begin show_elem(temp); k:=k+1; end;

                 2: If temp^.x.lim=min then

                 begin show_elem(temp); k:=k+1; end;

                 1: If temp^.x.rat=min then

                 begin show_elem(temp); k:=k+1; end;

                 end;

                 If k=5 then begin

                         show_tabl_down;

                         write(' push <Space> - look further'); readln;

                         clrscr; wherex; k:=0; show_tabl_up;

                       end;

                 temp:=temp^.y;

               end;

               show_tabl_down;

              end;

  end;

readkey; clrscr;

end;

procedure sr_(top:p; poz_sr:integer);

var temp:p; k:longint; sum,sr:real;

begin

  sum:=0; k:=0; sr:=0;

  IF top=nil then begin window(1,10,20,15);writeln('  Table is empty!');end

          else

  begin

    temp:=top;

    while temp<>nil do

      begin

     case poz_3 of

        1: begin sum:=sum+temp^.x.rat; k:=k+1; end;

     2: begin sum:=sum+temp^.x.dur; k:=k+1; end;

     end;

     temp:=temp^.y;

      end;

    sr:=sum/k;

    window(1,10,25,15);

    writeln('Average value = ',sr:3:3);

  end;

readkey; clrscr;

end;

procedure trassa(num_k:integer);

begin

  case num_k of

  11 : new_fail(top_za);

  12 : chtenie(top_za);

  13 : save_(top_za);

  14 : save_text(top_za);

  21 : add_znach(a,top_za);

  221: begin window(15,30,15,15);poz_0:=1; tip:=1; find_(top_za,n,poz_0,tip); end;

  222: begin window(15,30,15,15);poz_0:=2; tip:=2; find_(top_za,n,poz_0,tip); end;

  223: begin window(15,30,15,15);poz_0:=3; tip:=3; find_(top_za,n,poz_0,tip); end;

  224: begin window(15,30,15,15);poz_0:=4; tip:=4; find_(top_za,n,poz_0,tip); end;

  23 : del_(top_za,n);

  24 : change(top_za,n);

  31 : show(top_za);

  32 :stran(top_za);

  331: begin poz_1:=1; max_(top_za,poz_1); end;

  332: begin poz_1:=2; max_(top_za,poz_1); end;

  333: begin poz_1:=3; max_(top_za,poz_1); end;

  341: begin poz_2:=3; min_(top_za,poz_2); end;

  342: begin poz_2:=2; min_(top_za,poz_2); end;

  343: begin poz_2:=1; min_(top_za,poz_2); end;

  351: begin poz_3:=1; sr_(top_za,poz_3); end;

  352: begin poz_3:=2; sr_(top_za,poz_3); end;

  36:sort(top_za);

  end;

  clrscr;

end;