BT 6.3 Cho số tự nhiên n(n<256).Xây dựng tập tất cả các số chính phương <= n.
for i:=0 to n do if frac(sqrt(i))=0 then A:=A+[i]; writeln('Tap cac so chinh phuong <= ',n,' la:');
Trang 2writeln('De dung nhap chon so 0 o cuoi day!'); writeln('Nhap mon an cho nguoi thu nhat:');
Trang 3NhapDS(A,'A'); NhapDS(B,'B'); NhapDS(C,'C'); P:=A*B*C; Q:=A-(B+C); R:=B-(A+C); S:=C-(B+A); writeln('Danh sach ban cua nguoi A la:'); InDS(A); writeln('Danh sach ban cua nguoi B la:'); InDS(B); writeln('Danh sach ban cua nguoi C la:'); InDS(C); writeln('Ban chung cua 3 nguoi la:'); InDS(P); writeln('Ban rieng cua nguoi A la:'); InDs(Q); writeln('Ban rieng cua nguoi B la:'); InDs(R); writeln('Ban rieng cua nguoi C la:'); InDs(S);
Tap:=[]; ChuCai:=['A' 'Z','a' 'z']; ChuSo:=['0' '9']; writeln('Nhap cac ki tu tuy y(Nhap Enter-ket thuc!)');
if chr(i) in Tap-(ChuSo+ChuCai) then write(chr(i):2); writeln('Da hoan thanh xong.An phim enter de tro ve!'); readln;
End.
Trang 4BT 6.9 Ban ve may bay so ghe toi da la 255
writeln('Danh sach cac ghe con trong!');
for gh:=1 to 250 do if gh in V then write(gh:4);
write('Nhap so sv trong lop:'); readln(n); until (n>0) and (n<=max);
writeln('Nhap ho so cho SV trong lop!');
write('Ho va Ten:'); readln(hoten); write('Diem Toan:'); readln(dtoan); write('Diem Tin:'); readln(dtin);
write('Diem Ngoai Ngu:'); readln(dngng);
Trang 5write('Cho so SV trong lop :'); readln(n); until (n>0) and (n<=max);
write('Ho va ten:'); readln(hoten); write('Ngay sinh:'); readln(ng); write('Thang sinh:'); readln(th); write('Nam sinh:'); readln(nam);
or ((sv[j-1].NS.nam = sv[j].NS.nam) and ( sv[j-1].NS.th > sv[j].NS.th))
or ((sv[j-1].NS.nam = sv[j].NS.nam) and ( sv[j-1].NS.th = sv[j].NS.th) and (sv[j-1].NS.ng > sv[j].NS.ng))
Trang 6write('Cho so nhan vien trong xi nghiep:'); readln(n); until (n>0) and (n<=max);
writeln('Nhap ho so cho nhan vien trong xi nghiep!');
write('Ho va ten:'); readln(hoten); write('Luong co ban:'); readln(lcb); write('So ngay cong:'); readln(nc); write('Phu cap:'); readln(pc); write('He so truot gia:');readln(tg);
Trang 7write('Co bao nhieu ho dung dien:'); readln(n); until (n>0) and (n<=max);
writeln('Nhap Ho So QLD cho cac ho!'); {Tinh tien dien}
write('Ho ten chu ho:'); readln(hoten); write('Chi so cu:'); readln(cscu); write('Chi so moi:'); readln(csmoi);
Trang 8write('Cho so SV trong khoa:'); readln(n); until (n>0) and (n<=max);
write('Nhap ho va ten dem:'); readln(ho); write('Nhap ten:'); readln(ten);
write('Nhap tuoi:'); readln(tuoi);
Trang 10writeln('CTrinh kiem tra su ton tai tep tin ten dia'); write('Cho biet ten tep tin:'); readln(fn);
writeln('Co tep ',fn,' Kich thuoc: ',filesize(f),' bytes') else writeln('Tep ',fn,' khong ton tai.');
writeln('Bam phim Enter de ket thuc!');
write('Cho ten tep tin:'); readln(fn); write('Cho eps='); readln(eps);
writeln(#10#13'Cac gia tri da duoc ghi vao tep ',fn); writeln('Bam Enter de ket thuc.');
Trang 11writeln('Sao chep tep so nguyen f'); write('Nhap ten tep tin f:'); readln(fn); write('Cho ten tep tin g:'); readln(gn); if not YNfile(fn) then
writeln('Da sao chep xong !'); writeln('An phim Enter de tro ve.');
writeln('Cho tep so nguyen f va tao tep g cac so chinh phuong cua f.'); write('Nhap ten tep f:'); readln(fn);
write('Cho ten tep tin g:');readln(gn); if not YNfile(fn) then
Trang 12writeln('Cho tep so nguyen f.Tao tep g,h cac so chan,le cua f.'); write('Nhap ten tep f:'); readln(fn);
write('Cho ten tep tin g:');readln(gn); write('Cho ten tep tin h:');readln(hn); if not YNfile(fn) then
Trang 13begin
read(h,x); write(x:4); end;
close(f); close(g); close(h);
writeln(#10#13,'Hoan thanh tot dep.An phim Enter !');
write('Cho 2 so tu nhien m,n:'); readln(m,n);
until (m>0) and (m<=max) and (n>0) and (n<=max); write('Nhap ten tep van ban luu tru:'); readln(fn);
writeln('Ma Tran duoc ghi trong tep: ', fn); writeln('Bam ESC ket thuc,phim khac tiep tuc !');
Trang 14write('Ptu thu ',i,' :'); readln(p); write(f,p);
end; close(f); end;
Procedure Sapxep; {tt chen truc tiep SX giam dan} var i,j:byte; p,q:integer;
writeln('Chuong trinh copy mot file bat ky !'); write('Nhap ten file nguon:'); readln(fn);
Trang 15procedure NhapHS(var f: FHosoTS);
var ts: HosoTS; ht: String[25]; i: Word; begin
Assign(f, fn); {$I-} Reset(f); {$I+};
if IOResult <> 0 then Rewrite(f); {Neu tep chua co thi tao moi} ClrScr;
Writeln('Nhap ho so thi sinh, go ho ten trong de ket thuc !'); i := FileSize(f) + 1;
repeat
Writeln('Nhap ho so cho thi sinh thu ', i); Write('Ho ten: '); Readln(ht);
if ht <> '' then begin
ts.hoten := ht;
Write('So bao danh: '); Readln(ts.sbd); Write('Diem mon 1, mon 2, mon 3: '); Readln(ts.mon1, ts.mon2, ts.mon3); Seek(f, i-1); Write(f, ts);
Trang 16procedure InDSPT(var f: FHosoTS);
var ts, ts1, ts2: HosoTS;
i, j, n: Word; pthi, stt: Byte; begin
{Sap xep theo ho ten thi sinh}
Assign(f, fn); Reset(f); {fn='HOSOTS.DAT'} n:= FileSize(f);
for i:= 0 to n - 2 do for j:= i+1 to n - 1 do begin
Seek(f, i); Read(f,ts1); Seek(f, j); Read(f,ts2); if ts1.hoten > ts2.hoten then
Seek(f, 0); {Dua con tro ve dau tep} pthi:= 1; {So phong thi tu 1} while not Eof(f) do
begin
Writeln('DANH SACH THI SINH THI TSDH NAM '); Writeln(' Phong thi so: ', pthi);
Assign(f, fn); Reset(f); {fn = 'HOSOTS.DAT'} while not Eof(f) do
begin Read(f, ts);
ts.tong:= ts.mon1 + ts.mon2 + ts.mon3;
if ts.tong >= 22 then ts.kq:= 'DO' else ts.kq:= 'TRUOT'; Seek(f, FilePos(f)-1); {Dua con tro tep ve vi tri cu}
Trang 17procedure InKQ(var f: FHosoTS);
var ts, ts1, ts2: HosoTS;
i, j, n: Word; soto, stt: Byte; begin
Assign(f, fn); Reset(f); {fn = 'HOSOTS.DAT'} {Sap xep giam theo tong diem}
n:= FileSize(f); for i:= 0 to n - 2 do for j:= i+1 to n - 1 do begin
Seek(f, i); Read(f,ts1); Seek(f, j); Read(f,ts2); if ts1.tong < ts2.tong then
begin
Seek(f, j); Write(f,ts1); Seek(f, i); Write(f,ts2); end;
end;
{In danh sach ket qua thi}
ClrScr; Seek(f, 0); {Dua con tro ve dau tep} soto:= 1; {So to tu 1}
while not Eof(f) do begin
Writeln('KET QUA THI TUYEN SINH DAI HOC '); Writeln(' To so: ', soto);
Write('Nhap so bao danh x: ');readln(x); while not Eof(f) do
Trang 18If d=0 then Writeln('Khong tim thay, vui long nhap lai!'); Write(#10#13,'An phim ENTER tiep tuc ');
Readln; Close(f); end;
procedure Thongke(var f: FHosoTS);
var ts: HosoTS; x:Byte;
Writeln(' 1 Nhap ho so thi sinh'); Writeln(' 2 In danh sach phong thi'); Writeln(' 3 Tinh toan va xet ket qua'); Writeln(' 4 Xem ket qua thi theo SBD'); Writeln(' 5 In bang ket qua thi');
Writeln(' 6 Thong ke ket qua thi'); Writeln(' 7 Thoat');
Writeln;
Write (' Ban chon viec nao 1/2/ /7 ? '); CASE ReadKey OF
'1': NhapHS(f); '2': InDSPT(f); '3': Tinhtoan(f); '4': XemKQ(f); '5': InKQ(f); '6': Thongke(f);
Trang 19writeln(' CHUONG TRINH NHAP HO SO THI SINH'); write('Cho so thi sinh du thi n = '); Readln(n);
write('Ho va ten:'); readln(hoten); write('So bao danh:'); readln(SBD);
write('Diem mon1, mon2, mon3:'); readln(mon1,mon2,mon3);
Trang 20{In danh sach phong thi} clrscr;
pthi:=1; i:=1; stt:=1;
While (i<=n) and (stt<=n) do begin
writeln(' DANH SACH PHONG THI'); writeln(' pthi so:',pthi);
if d=0 then writeln('Khong tim thay, vui long nhap lai!'); writeln('An phim Enter tiep tuc !');
Trang 21if ts[i].tong>=22 then inc(d);
if d<>0 then writeln('Co ', d ,' thi sinh trong DS do DH!')
Trang 22writeln('1.Nhap ho so thi sinh'); writeln('2.In danh sanh phong thi'); writeln('3.Tinh toan va xet ket qua'); writeln('4.Xem ket qua thi sinh theo SBD'); writeln('5.In bang ket qua thi');
writeln('6.Thong ke ket qua thi'); writeln('7.Thoat');
writeln;
write('Ban chon viec nao 1/2/ /7 ?'); CASE ReadKey OF
'1':NhapHS; '3':Tinhtoan; '5':InKQ; '2':InDSPT; '4':XemKQ; '6':Thongke;
Trang 23writeln('Xoa cac so trong danh sach nho hon k'); write('Cho so nguyen k= '); readln(k);
Writeln('Cac so nguyen ban dau la:'); InDS; XoaPT; writeln('Cac so con lai sau khi xoa la:'); InDS; write('An Enter de tro ve!');
Readln; END.