giúp em với! bài tập lớn!
Trang 1 trong tổng số 1 trang
giúp em với! bài tập lớn!
các anh chị lý giải hộ em cái chương trình này với!
{Tra cuu sach }
Function ChonLoaiTracuu:integer;
var chon:integer;
begin
chon:=-1;
while (chon<0)or(chon>3) do
begin
writeln('Moi ban chon loai tra cuu:');
writeln('Chon 1 de tra cuu theo ten sach');
writeln('Chon 2 de tra cuu theo ten tac gia');
writeln('Chon 3 de tra cuu theo ma sach');
writeln('Chon 0 de thoat');
readln(chon);
if (chon<0) or (chon>3) then
begin
writeln('Ban chon sai roi an enter de chon lai');
readln;
end
else break;
end;
chonloaitracuu:=chon;
end;
{==========================================================================}
function CoXau1TrongXau2(s1:xau200;s2:xau200):boolean;
begin
CoXau1TrongXau2:= Pos(s1,s2)>0;
end;
{==========================================================================}
procedure TraCuuTheoTenSach;
var loaisach:DuLieuLoaiSach;
tentracuu:xau200;
dem:integer;
begin
writeln('Moi ban nhap ten sach muon tim (viet lien khong dau):');
read(tentracuu);
MoFile2(doc);
dem:=0;
while (not eof(f2)) do
begin
read(f2,loaisach);
if (CoXau1TrongXau2(tentracuu,loaisach.tensach)) then
begin
dem:=dem+1;
writeln('Sach: ',loaisach.tensach);
writeln('Tac gia: ',loaisach.tentacgia);
writeln('Ma loai: ',loaisach.maloai);
writeln('So luong: ',loaisach.soluongsach);
writeln;
end;
end;
if(dem=0) then writeln('Sach ban tim khong co trong thu vien');
DongFile2;
readln;
end;
{==========================================================================}
procedure TraCuutheoTacGia;
var loaisach:DuLieuLoaiSach;
tentracuu:xau200;
dem:integer;
begin
writeln('Moi ban nhap ten tac gia muon tim (viet lien khong dau):');
read(tentracuu);
MoFile2(doc);
dem:=0;
while (not eof(f2)) do
begin
read(f2,loaisach);
if (CoXau1TrongXau2(tentracuu,loaisach.tentacgia)) then
begin
dem:=dem+1;
writeln('Sach:',loaisach.tensach);
writeln('Tacgia:',loaisach.tentacgia);
writeln('Ma loai:',loaisach.maloai);
writeln('So luong con:',loaisach.soluongsach);
writeln;
end;
end;
DongFile2;
if(dem=0) then writeln('Sach ban tim khong co trong thu vien');
readln;
end;
{==========================================================================}
procedure TraCuuTheoMaSach;
var loaisach:DuLieuLoaiSach;
matracuu:integer;
dem:integer;
begin
writeln('Moi ban nhap ma loai tra cuu:');
read(matracuu);
MoFile2(doc);
dem:=0;
while(not eof(f2)) do
begin
read(f2,loaisach);
if (matracuu=loaisach.maloai) then
begin
dem:=dem+1;
writeln('Sach: ',loaisach.tensach);
writeln('Tacgia: ',loaisach.tentacgia);
writeln('Ma loai: ',loaisach.maloai);
writeln('So luong con: ',loaisach.soluongsach);
writeln;
end;
end;
Dongfile2;
if(dem=0) then writeln('Sach ban tim khong co trong thu vien');
readln;
end;
{==========================================================================}
procedure Tracuusach;
var loaitracuu:integer;
begin
loaitracuu:=ChonLoaiTraCuu;
case loaitracuu of
1 : TraCuuTheoTenSach;
2 : TraCuuTheoTacGia;
3 : TraCuuTheoMaSach;
end;
end;
em đang làm bài tập lớn cho phần quản lý thư viện!
đây là bài viết 1 phần chương trình của bạn em! nhưng em ko hiểu vì sao lại dùng cachs này!
anh chị có thể giúp em giải thích cặn kẽ hơn về nội dung các lệnh các hàm các ý nghĩa trong phần chương trình này được ko ạ!
{Tra cuu sach }
Function ChonLoaiTracuu:integer;
var chon:integer;
begin
chon:=-1;
while (chon<0)or(chon>3) do
begin
writeln('Moi ban chon loai tra cuu:');
writeln('Chon 1 de tra cuu theo ten sach');
writeln('Chon 2 de tra cuu theo ten tac gia');
writeln('Chon 3 de tra cuu theo ma sach');
writeln('Chon 0 de thoat');
readln(chon);
if (chon<0) or (chon>3) then
begin
writeln('Ban chon sai roi an enter de chon lai');
readln;
end
else break;
end;
chonloaitracuu:=chon;
end;
{==========================================================================}
function CoXau1TrongXau2(s1:xau200;s2:xau200):boolean;
begin
CoXau1TrongXau2:= Pos(s1,s2)>0;
end;
{==========================================================================}
procedure TraCuuTheoTenSach;
var loaisach:DuLieuLoaiSach;
tentracuu:xau200;
dem:integer;
begin
writeln('Moi ban nhap ten sach muon tim (viet lien khong dau):');
read(tentracuu);
MoFile2(doc);
dem:=0;
while (not eof(f2)) do
begin
read(f2,loaisach);
if (CoXau1TrongXau2(tentracuu,loaisach.tensach)) then
begin
dem:=dem+1;
writeln('Sach: ',loaisach.tensach);
writeln('Tac gia: ',loaisach.tentacgia);
writeln('Ma loai: ',loaisach.maloai);
writeln('So luong: ',loaisach.soluongsach);
writeln;
end;
end;
if(dem=0) then writeln('Sach ban tim khong co trong thu vien');
DongFile2;
readln;
end;
{==========================================================================}
procedure TraCuutheoTacGia;
var loaisach:DuLieuLoaiSach;
tentracuu:xau200;
dem:integer;
begin
writeln('Moi ban nhap ten tac gia muon tim (viet lien khong dau):');
read(tentracuu);
MoFile2(doc);
dem:=0;
while (not eof(f2)) do
begin
read(f2,loaisach);
if (CoXau1TrongXau2(tentracuu,loaisach.tentacgia)) then
begin
dem:=dem+1;
writeln('Sach:',loaisach.tensach);
writeln('Tacgia:',loaisach.tentacgia);
writeln('Ma loai:',loaisach.maloai);
writeln('So luong con:',loaisach.soluongsach);
writeln;
end;
end;
DongFile2;
if(dem=0) then writeln('Sach ban tim khong co trong thu vien');
readln;
end;
{==========================================================================}
procedure TraCuuTheoMaSach;
var loaisach:DuLieuLoaiSach;
matracuu:integer;
dem:integer;
begin
writeln('Moi ban nhap ma loai tra cuu:');
read(matracuu);
MoFile2(doc);
dem:=0;
while(not eof(f2)) do
begin
read(f2,loaisach);
if (matracuu=loaisach.maloai) then
begin
dem:=dem+1;
writeln('Sach: ',loaisach.tensach);
writeln('Tacgia: ',loaisach.tentacgia);
writeln('Ma loai: ',loaisach.maloai);
writeln('So luong con: ',loaisach.soluongsach);
writeln;
end;
end;
Dongfile2;
if(dem=0) then writeln('Sach ban tim khong co trong thu vien');
readln;
end;
{==========================================================================}
procedure Tracuusach;
var loaitracuu:integer;
begin
loaitracuu:=ChonLoaiTraCuu;
case loaitracuu of
1 : TraCuuTheoTenSach;
2 : TraCuuTheoTacGia;
3 : TraCuuTheoMaSach;
end;
end;
em đang làm bài tập lớn cho phần quản lý thư viện!
đây là bài viết 1 phần chương trình của bạn em! nhưng em ko hiểu vì sao lại dùng cachs này!
anh chị có thể giúp em giải thích cặn kẽ hơn về nội dung các lệnh các hàm các ý nghĩa trong phần chương trình này được ko ạ!
nopd_pinkpong- Tổng số bài gửi : 1
Join date : 28/12/2010
Similar topics
» Bài tập Pascal
» Bài tập Pascal nè các bạn ơi!!!!!!!!
» Bài tập Pascal sử dụng kiểu mảng, có giải. :D
» Các bài tập Pascal cơ bản cho các bạn mới học lập trình!!
» Bài tập Pascal nè các bạn ơi!!!!!!!!
» Bài tập Pascal sử dụng kiểu mảng, có giải. :D
» Các bài tập Pascal cơ bản cho các bạn mới học lập trình!!
Trang 1 trong tổng số 1 trang
Permissions in this forum:
Bạn không có quyền trả lời bài viết
|
|