pcsach

Màu nền
Font chữ
Font size
Chiều cao dòng

program quanlysach;

uses crt;

   type  contro=^sach;

         sach=record

        masach:string[6];

        tensach:string[20];

        nxb:string[30];

        tiep:contro;

        case loaisach:string[15] of

          'giaotring':(doituong:string[15]);

          'tapchi':   (chude:string[15]);

   end;

    var ct,ctdau,ctcuoi:contro;

        lam:char;

        chon:integer;

   procedure taoLIFO;

     begin

        ctcuoi:=nil;

        repeat

        new(ct);

       with ct^ do

       begin

         write('nhap ma sach:');readln(masach);

         write('nhap tensach:');readln(tensach);

         write('nhap nha xuat ban:');readln(nxb);

         write('nhap loai sach:');readln(loaisach);

            if loaisach='giaotrinh' then

            begin

         write('nhap doi tuong doc gia:');readln(doituong);

            end;

           if loaisach='tapchi' then

           begin

          write('nhap chu de:');readln(chude);

          end;

          tiep:=ctcuoi;

          ctcuoi:=ct;

          end;

       writeln('ban muon nhap tiep hay thoi (c/k)?');readln(lam);

        until upcase(lam)='K';

         end;

   procedure docLIFO;

       begin

       ct:=ctcuoi;

         writeln('dach sach hien tu cuoi ve dau la:');

         while ct<>nil do

       begin

        with ct^ do

        writeln(masach,' ',tensach,' ',nxb,' ',loaisach,' ',doituong,' ',chude);

        ct:=ct^.tiep;

         end;

         end;

   procedure xuly;

     begin

      ct:=ctcuoi;

       writeln('hien danh sach sach co loai sach la giao trinh');

       while ct <> nil do

       begin

         with ct^ do

         if loaisach='giaotrinh' then

         writeln(masach,' ',tensach,' ',nxb,' ',loaisach,' ',doituong);

         ct:=ct^.tiep;

         end;

         end;

   procedure taoFIFO;

      begin

      ctdau:=nil;

      repeat

      new(ct);

        with ct^ do

      begin

        write('nhap ma sach:');readln(masach);

        write('nhap ten sach:');readln(tensach);

        write('nhap nah xuat ban:');readln(nxb);

        write('nhap loai sach:');readln(loaisach);

         if loaisach='giaotrinh' then

         begin

           write('nhap doi tuong doc gia:');readln(doituong);

         end;

         if loaisach='tapchi' then

         begin

         write('nhap chu de:');readln(chude);

         end;

         if ctdau=nil then

         ctdau:=ct

         else

         ctcuoi^.tiep:=ct;

         ctcuoi:=ct;

         ctcuoi^.tiep:=nil

      end;

        writeln('ban muon nhap tiep hay khong (c/k)?');readln(lam);

        until upcase(lam)='K';

        end;

   procedure docFIFO;

      begin

      ct:=ctdau;

       writeln('dach sach hien tu dau xuong cuoi theo fifo la');

       while ct<> nil do

       begin

       with ct^ do

       writeln(masach,' ',tensach,' ',nxb,' ',loaisach,' ',doituong,' ',chude);

        ct:=ct^.tiep;

        end;

        end;

procedure xulyFIFO;

    begin

     ct:=ctcuoi;

     writeln('hien danh sach loai sach laf tap chi');

       while ct<> nil do

       begin

       with ct^ do

       if loaisach='tapchi' then

    writeln(masach,' ',tensach,' ',nxb,' ',loaisach,' ',doituong,' ',chude);

     ct:=ct^.tiep;

  end;

  end;

  procedure xlmasach;

      begin

        ct:=ctcuoi;

         writeln('thay ma sach vs ma sach moi la 4');

          while ct<> nil do

          begin

            with ct^ do

             if masach='123' then begin

             write('nhap nha xuat ban:');readln(nxb);

            ct:=addr(ct);

             end;

              ct:=ct^.tiep;

               end;

            end;

   begin

      clrscr;

       writeln('   CHUONG TRINH QUAN LY SACH    ');

       writeln('   nhan phim 1 de tao lifo      ');

       writeln('   nhan phim 2 de doc lifo      ');

       writeln('   nhan phim 3 xuly             ');

       writeln('   nhan phim 4 de tao fufo      ');

       writeln('   nhan phim 5 de doc fifo      ');

       writeln('   nhan phim 6 de xu ly fifo    ');

       writeln('   nhan phim 7 xlmasach         ');

       writeln('   nhan phim 8 de thoat         ');

       repeat

       writeln('   hay nhan phim');

       readln(chon);

       case chon of

       1:taoLIFO;

       2:docLIFO;

       3:xuly;

       4:taoFIFO;

       5:docFIFO;

       6:xulyFIFO;

       7:xlmasach

        end;

       until chon=8;

       readln;

       end.

Bạn đang đọc truyện trên: Truyen2U.Pro

#thu