P. 1
bai tap pacal

bai tap pacal

|Views: 53|Likes:
Publicado porlang48tin

More info:

Published by: lang48tin on Jan 24, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOCX, PDF, TXT or read online from Scribd
See more
See less

11/08/2012

pdf

text

original

Sections

  • 1/S p X p Theo Tên:
  • 2/S p x p i m t ng:
  • 3/Hóa n:
  • 4/Th vi n sách:
  • 5/H S Nhân Viên:
  • 6/Tính i m x p h ng:
  • 7/Hoán v chu i:
  • 8/Tách danh sách ch n l :
  • 9/ o ng c danh sách:
  • 10/Ghép Chu i:
  • 11/Cây nh phân (hay):
  • 12/ i th p phân ra nh phân:
  • 13/M ng kí t :
  • 14/Trung bình c ng:
  • 15/Chèn m t s vào hàng:
  • 16/Xóa ph n t trong m ng:
  • 17/Th ng kê các s l :
  • 18/Tính giá tr c a a th c b c N:
  • 19/ i s nguyên ki u Word ra h th p l c:
  • 20/ i s nguyên ki u Word ra h nh phân:
  • 21/C ng 2 s nguyên:
  • 22/Nhân 2 s nguyên:
  • 24/Tìm m t s trong m ng:
  • 25/Gi i h phu ng trình tuy n tính 2 n:
  • 26/Nhân ma tr n:
  • 27/Tìm và xóa các kí t trùng nhau trong chu i:
  • 28/Tìm chu i 2 xu t hi n trong chu i 1:
  • 29/ i s La mã ra s th p phân:
  • 30/Ki m tra s nh p vào:
  • 31/Chu ng trình mã hóa:
  • 32/Ng t t ng t trong câu:
  • 33/Ki m tra kí t trùng c a 2 chu i:
  • 34/Ki m tra chu i i x ng:
  • 35/ i s th p phân ra s la mã:
  • 36/Mãng s th c:
  • 37/T ng tích ma tr n:
  • 38/S p x p m ng t ng d n:
  • 39/S p x p m ng b ng gi i thu t chèn:
  • 40/S p x p m ng b ng gi i thu t ch n:
  • 41/S p x p m ng b ng gi i thu t n i b t:
  • 42/Gi i thu t tìm ki m tuy n tính:
  • 43/Gi i thu t tìm ki m nh phân:
  • 44/Xóa b các s trùng nhau:
  • 45/Dãy con:
  • 46/Ch hoa:
  • 47/Tam giác Pascal:
  • 48/Phân tích s nguyên du ng nh nh t:
  • 49/B ng c u chu ng:
  • 50/Tìm 2 ph n t liên ti p trong b ng X:

1/S p X p Theo Tên: CODE (Ch n t t c

)
Program Sap_Xep_Theo_Ten; TYPE ConTro = ^HoSo; HoSo = RECORD HoLot : String[17]; Ten : String[7]; Diem : Real; End; VAR a : Array[1..50] Of HoSo; Tam : ConTro; i,j,PhanTu : Integer; BEGIN PhanTu := 0; New(Tam); With Tam^ Do Repeat Write('-Nhap ho lot ( 0 de ket thu): '); Readln(HoLot); If HoLot <> '0' Then Begin Write('-Nhap ten : '); Readln(Ten); Write('-Nhap diem : '); Readln(Diem); PhanTu := PhanTu + 1; a[PhanTu] := Tam^; End; Until HoLot = '0'; For i := 1 To PhanTu - 1 Do For j := PhanTu DownTo i+1 Do If a[j].Ten[1] < a[j-1].Ten[1] Then Begin Tam^ := a[j]; a[j] := a[j-1]; a[j-1] := Tam^; End; Writeln; Writeln('------------------------------------'); Writeln('| HO VA TEN | DIEM |'); Writeln('|--------------------------|-------|'); For i := 1 To PhanTu Do With a[i] Do Writeln('|',HoLot:17,' ',Ten:7,' |',Diem:5:1,' Writeln('------------------------------------'); Readln END.

|');

2/S p x p i m t ng: CODE (Ch n t t c )
Program Sap_Xep_Diem_Tang;

TYPE ConTro = ^Lop; Lop = RECORD HoTen : String[24]; NamSinh : Integer; DiemTb : Real; End; VAR Hs : Array[1..50] Of lop; i,j,n : Integer; Tam : ConTro; Begin Writeln('SAP XEP DIEM TANG DAN);'); Writeln('Giai thuat noi Buble'); Writeln('--------------------'); New(Tam); Writeln; Write('-So hoc sinh: '); Readln(n); For i := 1 To N Do With Hs[i] Do Begin Write('+Ho ten hoc sinh thu: ',i:2,' la: '); Readln(Hoten); Write('+Nam sinh: '); Readln(NamSinh); Write('+Diem trung binh: '); Readln(DiemTb); End; For i := 1 To N-1 Do For j := 1 To N-i Do If Hs[j].DiemTb > Hs[j+1].DiemTb Then Begin Tam^ := Hs[j]; Hs[j] := Hs[j+1]; Hs[j+1] := Tam^; End; Writeln; Writeln(' DANH SACH SAP XEP'); Writeln; For i := 1 To N Do With Hs[i] Do Writeln('-',HoTen:24,' :',Namsinh:4,' , ',DiemTb:5:2); Readln End.

3/Hóa

n:

CODE (Ch n t t c )
Program Hoa_Don; CONST Max = 100; TYPE ConTro = ^HoaDon; HoaDon = RECORD NguoiMua : String[24];

TenHang : String[10]; DonGia : Real; SoLuong : Integer; End; VAR a : Array[1..Max] Of HoaDon; DsTenHang : Array[1..Max] Of String[10]; Tam : ConTro; Spt, SoTenHang, i, j : Integer; Tong : Real; KiemTra : Boolean; BEGIN Writeln('HOA DON BAN HANG'); Writeln('----------------'); Writeln; Spt := 0; New(Tam); With Tam^ do Repeat Write('-Ten nguoi mua (go 0 de thoat): '); Readln(NguoiMua); If NguoiMua <> '0' Then Begin Write('-Ten hang: '); Readln(TenHang); Write('-Don gia : '); Readln(DonGia); Write('-So luong: '); Readln(SoLuong); Spt := Spt + 1; a[Spt] := Tam^; End; Until NguoiMua = '0'; SoTenHang := 0; For i := 1 To Spt Do Begin KiemTra :=False; For j := 1 To SoTenHang Do If DsTenHang[j] = a[i].TenHang Then KiemTra := True; If NOT KiemTra Then Begin SoTenHang :=SoTenHang + 1; DsTenHang[SoTenHang]:=a[i].TenHang; End; End; Writeln; For i := 1 To SoTenHang Do Begin Tong := 0; For j := 1 To Spt Do With a[j] Do If TenHang = DsTenHang[i] Then Tong := Tong + (DonGia * Soluong); Writeln(' +Tong so tien mua: ',DsTenHang[i]:10,' = ',tong:10:2);

End; Readln END.

4/Th vi n sách: CODE (Ch n t t c )
Program Thu_Vien; Uses Crt; TYPE ConTro = ^ThuVien; ThuVien = RECORD TenSach : String[30]; TacGia : String[24]; Namxb : Byte; NguoiMuon: String[24]; Next : ConTro; End; VAR First,Last,Newp : ConTro; ds,dm : Integer; Ch : Char; HeapTop : ^Integer; BEGIN ClrScr; GotoXY(5,25); Write('Bam <Enter> de tiep tuc, bam <Esc> de thoat'); Window(1,1,80,24); Writeln('QUAN LY THU VIEN'); Writeln('----------------'); Writeln; ds := 0; dm := 0; First := Nil; Mark(Heaptop); Repeat New(Newp); With Newp^ Do Begin Write('-Ten sach : '); Readln(TenSach); If TenSach <> '' Then Begin ds := ds + 1; Write('-Tac Gia: '); Readln(TacGia); Write('-Nam xuat ban : '); Readln(Namxb); Write('-Nguoi muon (Khong co ai muon thi bam <Enter>: '); Readln(NguoiMuon); If NguoiMuon <> '' Then dm := dm + 1; End; End; If First = Nil Then

Ch := ReadKey. Writeln('----------------'). Ch : Char. Release(HeapTop). HoSo = RECORD HoTen : String[24]. Writeln('+Tong so sach: '.TacGia). Writeln('QUAN LY THU VIEN').LuongTb : LongInt.TenSach). Writeln('-Nam Xuat ban: '. LuongMax. Writeln('-Nguoi muon : '. 5/H S Nhân Viên: CODE (Ch n t t c ) Program Ho_So_Nhan_Vien. LuongMin. Writeln. Writeln('HO SO NHAN VIEN'). Last. Begin ClrScr.Next := Nil. Hoten1. VAR First.Namxb).25). Last :=Newp.TuoiMax. End. Readln END. .First := Newp Else Last^.Ds). Writeln.TuoiMin : Integer. Hoten2 : String[24]. Until Ch = #27. HeapTop :^Integer.80.NguoiMuon). Write('Bam <Enter> de tiep tuc. Writeln('---------------'). Writeln. ClrScr. Tuoi : Integer.25). Next : ConTro. GoToXY(5. While First <> Nil Do With First^ Do Begin Writeln('-Ten sach: '. TYPE ConTro = ^HoSo. Write(' Bam <Esc> de thoat'). Last^.Next := Newp.Dm). i. First := Next. End. Uses Crt. Newp : ConTro.2. bam <Esc> de thoat '). Writeln('+So sach cho muon: '. Window(1. Luong : LongInt. Writeln('-Tac gia : '.

Writeln('+Nhan vien: '.LuongMin:10). Readln(Tuoi). End Else If Luong < LuongMin Then Begin LuongMin := Luong. Mark(HeapTop). End. LuongMax := Luong. Write('-Bac luong = ').' . HoTen1 := HoTen.i:2. First := Next. i := 0. . Writeln('Nhan vien co tuoi lon nhat la: '.' .co bac luong lon nhat: '. Repeat i := i + 1.Next := Newp.LuongMax:10). If First = Nil Then First := Newp Else Last^. Readln(Luong). TuoiMax := Tuoi. Writeln('Nhan vien: '.TuoiMax). Until Ch = #27. LuongMin := Luong. If Luong > LuongMax Then Begin LuongMax := Luong. Writeln('Nhan vien co tuoi nho nhat la:'. HoTen2 := HoTen.co bac luong nho nhat: '.HoTen1. Write('-Tuoi = '). Release(HeapTop).First :=Nil.' la= ').TuoiMin). End. End. New(Newp). While First <> Nil Do With First^ Do Begin If Tuoi > TuoiMax Then TuoiMax := Tuoi Else If Tuoi < TuoiMin Then TuoiMin := Tuoi. Writeln. With Newp^ Do Begin Write('-Ho ten nhan vien thu: '.HoTen2. Readln(HoTen). Writeln. Ch := ReadKey. HoTen1 := HoTen. Last^. Last := Newp. TuoiMin := Tuoi.Next := Nil. HoTen2 := HoTen.

Write(' +Diem trung binh hoc ky 2: '). Lop = RECORD HoTen : String[24]. Writeln. 6/Tính i m x p h ng: CODE (Ch n t t c ) Program Tinh_Diem_Xep_Hang.Tb Then Begin Tam^ := Hs[j]. Writeln.i:2.Tb2. Hs[j+1] := Tam^.Tb : Real. VAR Hs : Array[1. Writeln('Giai thuat noi Buble'). Tam : ConTro. Begin Writeln('TINH DIEM VA XEP HANG).' la: '). For i := 1 To N Do Begin . Readln End. New(Tam). Readln(Tb1). TYPE ConTro = ^Lop.n.Tb < Hs[j+1]. Tb :=(Tb1 + Tb2)/2. Write('-So hoc sinh: ').'). i. Readln(Tb2). Tb1. Hs[j] := Hs[j+1]..Hang: Integer. Write(' +Diem trung binh hoc ky 1: '). NamSinh : Integer. Hang := 1.j. Writeln.Writeln. Readln(Hoten).50] Of lop. End. For i := 1 To N-1 Do For j := 1 To N-i Do If Hs[j]. Readln(n). Readln(NamSinh). Writeln. Write(' +Nam sinh: '). For i := 1 To N Do With Hs[i] Do Begin Write(' +Ho ten hoc sinh thu: '. End. Writeln('--------------------'). Write(' Bam <Enter> de ket thuc '). Writeln(' DANH SACH XEP HANG'). End.

TYPE Mang = Array[1. Uses Crt.Hang). Writeln.Hoc sinh : '.Chuoi2^). . Chuoi1 := Chuoi2. Dispose(Chuoi1). Writeln. Begin ClrScr. Writeln.Tb <> Hs[i-1]. Chuoi1^ := 'Giao trinh Turbo Pascal 7. New(Chuoi2). Writeln('-Chuoi thu hai : '. New(Chuoi1). Chuoi2 := Tam. Writeln('HOAN VI 2 CON TRO THAY CHO HOAN VI NOI DUNG'). Tam := Chuoi1.Chuoi1^)..Tb:5:2). Writeln('-Chuoi thu hai : '. Writeln('----------------------------'). .Hs[i]. Dispose(Chuoi2).Xep hang ca nam : '.Chuoi2^).Nam sinh : '.0'.Diem trung binh ca nam : '. End. End. VAR Chuoi1. Writeln('-Chuoi thu nhat: '. Write(' Bam <Enter> .If (i > 1) And (Hs[i]. 7/Hoán v chu i: CODE (Ch n t t c ) Program Hoan_Vi_Chuoi. Readln.Hs[i].Hs[i]. Writeln(' . Chuoi2^ := 'Giao trinh FoxPro 2.NamSinh). Writeln(' . Writeln(' .Tam :^String. Readln End. Writeln. Writeln. '). Writeln(' .Chuoi1^).100] Of Integer.HoTen). Writeln('-Chuoi thu nhat: '.6'. Uses Crt.Tb) Then Hang := i. Writeln('NOI DUNG BAN DAU CUA 2 CHUOI'). Writeln. Writeln('-------------------------------------------'). Writeln('----------------------------------'). Writeln('NOI DUNG SAU KHI HOAN VI 2 CON TRO').Chuoi2. . 8/Tách danh sách ch n l : CODE (Ch n t t c ) Program Tach_Danh_Sach_Chan_Le.

i:2. Writeln. 9/ o ng c danh sách: CODE (Ch n t t c ) Program Dao_Nguoc_Danh_Sach. Writeln. j := j + 1. Writeln. Writeln. End.' '). Readln(a[i]). a. Writeln('----------------------'). Writeln(' -Danh sach thu hai ( so chan ) '). End. Next : ConTro. End.' '). . For i := 1 To j-1 Do Write(b[i]. End Else Begin c[k] :=a[i]. Writeln. ').VAR i.c : Mang. Write('-So phan tu: '). Readln(n). Writeln(' -Danh sach thu nhat ( so le ) '). For i := 1 To n Do Begin Write('-Phan tu thu: '. k := 1.j. Begin ClrScr. Writeln. Writeln(' --------------'). k := k + 1. Uses Crt. . Write(' Bam <Enter> . For i := 1 To k-1 Do Write(c[i]. Writeln(' NHAP DANH SACH').n : Integer. . j := 1. Writeln. Nut = RECORD So : Integer. TYPE ConTro = ^Nut. Readln End.b. Writeln('TACH THANH 2 DANH SACH'). Writeln.k. For i := 1 To n Do If Odd(a[i]) Then Begin b[j] := a[i].' = ').

Readln END. BEGIN ClrScr. Ch : Char. Next : ConTro. TYPE ConTro = ^Nut.Next.Tam1. Ch : Char. Write(' Bam <Enter> . Repeat Tam2 := Tam1^. VAR Dau1. Repeat New(Tam1).VAR Nut1. Write('-Nhap so: '). BEGIN ClrScr. Writeln.Next := Nut1. Write(' Nhap nua khong ? (c/k) '). Tam1 := Tam2. Readln(Ch).Tam2 : ConTro. End. End. Nut1 := Nil. Dau2. Nut1 := Nil. Writeln(' DAO NGUOC DANH SACH'). Writeln(' -------------------'). Nut1 := Tam1. Until UpCase(Ch)= 'K'. Nut1 := Tam1.Next := Nut1. '). . Tam1 := Nut1. Uses Crt. Tam1 := Tam1^. Nut = RECORD Kt : Char.So). Tam1 := Nut1. Tam : ConTro. Until Tam1 = Nil.Cuoi2 : ConTro. .So:6). Writeln('Sau khi dao: ').Next. Tam1^.Cuoi1 : ConTro. . Readln(Tam1^. 10/Ghép Chu i: CODE (Ch n t t c ) Program Ghep_Chuoi. i : Integer. Tam1^. While Tam1 <> Nil Do Begin Write(Tam1^.

Kt). Tam := Tam^. Cuoi1 := Tam. End Else Begin Cuoi1^. Write('Nhap nua khong ? (c/k) '). New(Tam). Writeln('--------------'). Repeat i := i + 1. Readln(Ch). Writeln. Writeln.Next := Dau2. i := 0.Next := Tam.Next. Cuoi2^. If i = 1 Then Begin Dau1 := Tam. Tam := Dau1.i:2. If i = 1 Then Begin Dau2 := Tam. Cuoi1^.Kt). Until UpCase(Ch) = 'K'. Writeln(' KET QUA'). Writeln('--------------'). Readln(Ch).Writeln('CHUOI THU NHAT'). Readln(Tam^. Until UpCase(Ch) = 'K'.' : '). Write('-Ky tu thu: '. Readln(Tam^. i := 0. ClrScr.i:2. While Tam <> Nil Do Begin Write(Tam^. End. Repeat i := i + 1. Writeln. Writeln('---------'). Cuoi1 := Tam. . Write('-Ky tu thu: '. Writeln('CHUOI THU HAI'). Write('Nhap nua khong ? (c/k) '). End.Next := Tam. Writeln. End. Cuoi2 := Tam. Cuoi2 := Tam.Kt).' : '). End Else Begin Cuoi2^. New(Tam).Next :=Nil.

New(P). Trai := Nil.HoTen.HoTen. Nv : BanGhi).Trai Else P := P^.Luong. Begin If goc = Nil Then Begin New(Goc). Trai := Nil. With P^ Do Begin HoTen := NV. ConTro = ^BanGhi. Trai.HoTen Then P := P^. End Else Begin P := Goc. While P <> Nil Do Begin P1 := P. BanGhi = RECORD HoTen : Str. .Phai : ConTro. Luong := NV.P1 : ConTro. With Goc^ Do Begin HoTen := NV. Phai := Nil. Luong := NV.Luong. Ch : Char.Phai.HoTen <= P^. If Nv. TYPE Str = String[24]. Luong : Real. Ketthuc : Boolean. Nv : BanGhi.Write(' Readln END. VAR Goc : ConTro. . End. Uses Crt. {--------------------------------} Procedure Chen(Var Goc : ConTro. End. Var P. P1 := Nil. 11/Cây nh phân (hay): CODE (Ch n t t c ) Program Cay_Nhi_Phan. Bam <Enter> . . End. ').

Nhanh :(NhanhTrai.Trai := P Else P1^. End Else Begin P := P^. If P1 = Nil Then Goc := Q Else Begin . Q1 := Nil. Begin If Goc = Nil Then Writeln('Cay rong') Else Begin P := Goc.Trai. Nv : BanGhi). End.HoTen Then Begin P := P^. If P = Nil Then Writeln('Khong tim thay') Else Begin If (P^. While Q^.Trai = Nil) Then Q := P^.HoTen) Do Begin P1 := P.Phai Else Begin Q := P^. End.Phai := Nil.HoTen Then P1^.P1.Trai.Trai := P^.Phai := P.HoTen < P^.Q1 : ConTro. End.NhanhPhai). If Q1 <> Nil Then Begin Q1^.HoTen <=P1^.Phai := Q^. If NV.Phai. End. Var P.Trai. If Nv. {--------------------------------} Procedure Xoa(Var Goc : ConTro.Trai. Nhanh := NhanhPhai.Phai <> Nil Do Begin Q1 := Q.Q.Phai. P1 := Nil. Q^. End.HoTen <> Nv. Q := Q^. While (P <> Nil) And (P^. Nhanh := NhanhTrai. End. End.

chua co du lieu'). End.Luong:8:1). Var P : ConTro. . {--------------------------------} Procedure Tim(Goc : ConTro. Writeln. Writeln. {--------------------------------} Procedure LNRLietKe(Goc : ConTro). End. Dispose(P). Begin If Goc = Nil Then Begin Writeln('Cay rong.HoTen < P^.Trai). Writeln('2-Noi them vao cay'). {--------------------------------} BEGIN Repeat ClrScr.Phai. Nv : BanGhi). Writeln('3-Xoa khoi cay').HoTen) Do If NV. Writeln(Goc^. If P = Nil Then Writeln('Khong tim thay') Else Begin Writeln('Tim thay'). End.If Nhanh = NhanhTrai Then P1^. Writeln('--------------------------'). End.HoTen <> Nv.Luong:8:1). '.Trai <> Nil Then LNRLietKe(Goc^.HoTen.HoTen. End.Trai Else P := P^.Trai := Q Else P1^. Writeln('1-Khoi tao cay'). Writeln('CAC CHUC NANG CAY NHI PHAN').Phai := Q.Goc^. Writeln(P^. Begin P := Goc.Phai <> Nil Then LNRLietKe(Goc^. End.'. Writeln('5-Liet ke danh sach').' '. End.Phai). P^.HoTen Then P := P^. While (P <> Nil) And (P^. End. End Else Begin If Goc^. Writeln('4-Tim kiem tren cay'). End. If Goc^.

Readln(HoTen). KetThuc := False. End Else KetThuc := True. Readln(Luong). Writeln. Repeat With Nv Do Begin Write('-Ho ten hoac <Enter> de ngung: '). Goc := Nil. Until ketThuc. Until ketThuc. Writeln. If HoTen <> '' Then Begin Write('-Bac luong : ').Writeln('6-Ket thuc chuong trinh'). Write('Chon cac chuc nang tu 1 den 6: '). If HoTen <> '' Then Begin Write('-Bac luong : '). . Writeln('-----------------'). Writeln('3. End. Readln(Luong). KetThuc := False. Writeln. Chen(Goc. Writeln('2-NOI VAO CAY THEO THU TU').Nv). Readln(Ch). End Else KetThuc := True. Writeln('-------------------------'). Chen(Goc. End. End. '2' : Begin ClrScr. Writeln('Cay co thu tu LNR').Nv). Writeln. Repeat With Nv Do Begin Write('-Ho ten hoac <Enter> de ngung: ').XOA KHOI CAY'). End. Writeln('1-KHOI TAO CAY'). '3' : Begin ClrScr. Readln(HoTen). Case Ch Of '1' : Begin ClrScr. Writeln.

Readln(HoTen). End. Writeln. Writeln. KetThuc := False. Writeln('---------------------------'). End. Until KetThuc.'). If HoTen <> '' Then Xoa(Goc. Writeln. . '4' : Begin ClrScr.. End. '). Writeln('4TIM KIEM TREN CAY'). Writeln('Hien thi theo thu tu ABC. hoac <Enter> de ngung: '). Writeln.. ketThuc := False. Until Ch = '6' END. hoac <Enter> de ngung: ').Writeln('--------------'). . Readln(HoTen). Readln End. End. End. If HoTen <> '' Then Tim(Goc. Writeln.NV) Else KetThuc := True. '5' : Begin ClrScr. Write('Xem xong bam <Enter> . '6' : Begin Writeln('7KET THUC CHUONG TRINH'). Repeat With Nv Do Begin Write('Ho ten can tim.NV) Else KetThuc := True. End. . Until KetThuc. Writeln('5LIET KE NOI DUNG CAY'). Writeln('-------------------'). LNRLietKe(Goc). Repeat With Nv Do Begin Write('Ho ten can xoa.

13/M ng kí t : CODE (Ch n t t c ) Program Mang_Ky_Tu. Writeln('+So he 10 la : '. Writeln('------------------------'). Readln End. Writeln. Var i. He10:= He10 Div 2. N:=He10.Y:Word. Var a:Array[Char] Of Integer. Writeln.12/ i th p phân ra nh phân: CODE (Ch n t t c ) Program Doi_thap_phan_ra_nhi_phan.a[ch]). Tam). Begin Writeln('DOI SO TU HE THAP PHAN SANG HE NHI PHAN'). Until He10 = 0. He2:=' '. Str(Y. He2:=Tam + He2. Var He10. Writeln('Bam phim <Enter> de ket thuc').' ma ASCII = '. Writeln(' -----------------'). Writeln(' Bam phim <Enter> de ket thuc'). 14/Trung bình c ng: CODE (Ch n t t c ) Program Tb_cong.dem.Ch.tong:Integer. Begin Writeln('IN MA ASCII CUA CAC KY TU'). For Ch:='A' To 'Z' Do Begin a[Ch]:=Ord(Ch). End. Writeln.N.N). Readln End. Writeln('+Doi sang he 2 la: '. Writeln('-Ky tu: '. Ch:Char.so. Readln(He10). Repeat Y:=He10 Mod 2. . He2.Tam:String. Write('-Nhap so nguyen he thap phan: '). Writeln.He2).

dem:2. Writeln. Write('-Vao vi tri: '). Write('-Can che so: '). For i:=1 To spt Do Write(a[i]:6). Writeln('+Trung binh cong cua: '. For i:=1 to dem Do Tong:=Tong+A[i]. Write('-Nhap so nguyn: '). dem:=0. Writeln. End. Begin Writeln('CHEN MOT SO VAO MANG'). Readln End. End. Write('-Nhap so nguyen (-1 de ngung): ').. For i:=1 To spt Do Begin Write('-Phan tu A['. Var i. Write('-Co bao nhieu phan tu: '). Readln(a[i]). a:Array[1. Readln(vitri). Writeln. While so > 0 Do Begin dem:=dem+1. Readln(so). Tb:=Tong/dem. Writeln. Writeln('--------------------').Tb:8:2). Tong:=0. Writeln('MANG TRUOC KHI CHEN').100] Of Integer. so. A:Array[1. a[dem]:=so. Writeln(' Bam phim <Enter> de ket thuc '). Readln(so). Begin Writeln('TINH TRUNG BINH CONG CAC SO NGUYEN'). Writeln.' so vua nhap = '.100] Of Integer.']= '). Readln(so).vitri:Integer.spt:Integer. Readln(spt).. For i:=spt+1 Downto Vitri+1 Do a[i]:=a[i-1]. .Tb:Real. 15/Chèn m t s vào hàng: CODE (Ch n t t c ) Program Chen.i. Writeln('----------------------------------').

Writeln('----------------------'). For i:=vitri to spt . Readln(a[i]). Writeln(' MANG TRUOC KHI XOA'). Readln End. Writeln. Writeln(' ----------------').spt. Writeln. Readln(vitri). For i:=1 To spt Do Write(a[i]:6). Readln(spt)..100] Of Integer. Writeln. Writeln(' MANG SAU KHI XOA').i:2.1. Writeln. Var i. Write('-Mang co bo nhieu phan tu: '). spt:=spt+ 1. Writeln('MANG SAU KHI CHEN'). For i:= 1 to spt Do Write(a[i]:6). Readln End. For i:=1 To spt Do Write(a[i]:6). Writeln(' Bam phim <Enter> de ket thuc '). Write('-Vi tri muon xoa: '). spt:=spt . End. Writeln.vitri:Integer.']= '). Writeln. a:Array[1. 16/Xóa ph n t trong m ng: CODE (Ch n t t c ) Program Xoa_Pt. 17/Th ng kê các s l : CODE (Ch n t t c ) . Writeln.a[vitri]:=so.1 Do a[i]:=a[i+1]. Writeln(' -----------------'). Begin Writeln('XOA PHAN TU TRONG MANG'). Writeln. Writeln. For i:=1 To spt Do Begin Write('-Phan tu A['. Writeln.

Writeln('------------------------------'). Writeln.i:2.Program So_le. sole:=0..spt). Write('-Cho biet X= '). P:=a[n]. Writeln('+Tri cua da thuc P(x)= '. For i:=1 To spt Do Begin Write('-Phan tu A['. .spt.']= '). Writeln('-Tong so cac so le la: '. i. Write('-Can nhap bao nhieu so: '). Readln(spt). Readln(a[i])..255] Of Integer. Var a:Array[1. Readln(x). Writeln('------------------'). 18/Tính giá tr c a a th c b c N: CODE (Ch n t t c ) Program Da_thuc.i:2.n:Byte. Writeln. End. Readln(n). For i:= N Downto 0 Do Begin Write('-Cho biet he so A['. Readln(a[i]).p:Real.sole). Writeln.P:0:6). Readln End. Begin Writeln('TINH GIA TRI CUA DA THUC BAC N'). Write('-Cho biet bac cua da thuc: ').255] Of Real. For i:= N Downto 1 Do P:=x * p + a[i-1]. Begin Writeln('THONG KE CAC SO LE'). Writeln('-Tong so cac so da nhap: '. Writeln. For i:= 1 To spt Do Write(a[i]:6). x.']= '). Writeln. Writeln. End. i.sole:Byte. Var a:Array[1. For i:=1 To spt Do If Odd(A[i]) Then Inc(sole). Writeln(' Bam phim <Enter> de ket thuc ').

Writeln.$F] Of Char ='0123456789ABCDEF'. SoBinary[0]:=#16.. Writeln. SoHex:String[4]. Writeln('+Doi ra so he thap luc = $'. Begin Writeln('DOI SO NGUYEN KIEU WORD RA HE NHI PHAN'). Const KyTuHe2:array[0. Writeln('+So nguyen kieu Word = '. . SoHex[2]:= KyTuHe16[Hi(SoWord) AND $F].1] Of Char ='01'.Writeln. Writeln('--------------------------------------'). Writeln(' Readln End.soWord). Readln End. SoBinary:String[16].SoHex). SoHex[3]:= KyTuHe16[Lo(SoWord) SHR 4].soWord). Readln(SoWord). 19/ i s nguyên ki u Word ra h th p l c: CODE (Ch n t t c ) Program Doi_he_16. SoHex[1]:= KyTuHe16[Hi(SoWord) SHR 4]. Var SoWord:Word. SoHex[0]:=#4. Bam phim <Enter> de ket thuc '). Writeln('+So nguyen kieu Word = '. Begin Writeln('DOI SO NGUYEN KIEU WORD RA HE THAP LUC'). Const KyTuHe16:array[0. SoHex[4]:= KyTuHe16[Lo(SoWord) AND $F]. Var SoWord:Word. Writeln('--------------------------------------'). 20/ i s nguyên ki u Word ra h nh phân: CODE (Ch n t t c ) Program Doi_he_2. Writeln(' Bam phim <Enter> de ket thuc '). For i:=15 DownTo 0 Do If (SoWord AND (1 SHL i)) = (1 SHL i) Then SoBinary[16-i]:= KyTuHe2[1] Else SoBinary[16-i]:= KyTuHe2[0]. Write('-Nhap so kieu Word: ').. i:byte. Readln(SoWord). Writeln. Write('-Nhap so kieu Word: ').

Var a. For k:=0 To nb-1 Do b[spt-k]:=b[nb-k]. Readln End. Write('-Chu so thu: '. If na>nb Then nmax:=na Else nmax:=nb. Writeln('+SO THU NHAT (-1 de ket thuc) ').SoBinary). Until b[nb]=-1. Const spt=301. k. Begin ClrScr.nb. Repeat na:=na+1. Writeln('+SO THU HAI (-1 de ket thuc) '). Until a[na]=-1.nb.' = '). Writeln('----------------').na. 21/C ng 2 s nguyên: CODE (Ch n t t c ) Program Cong_so.Writeln('+Doi ra so he nhi phan= B '. Write('-Chu so thu: '.kq:Mang. For k:=1 to spt-nb Do b[k]:=0. Writeln('CONG 2 SO NGUYEN'). nb:=nb-1. na:=0.tam:Integer. Uses Crt. ClrScr.. For k:=1 to spt-na Do a[k]:=0. Writeln(' Bam phim <Enter> de ket thuc '). Repeat nb:=nb+1. For k:=0 To na-1 Do a[spt-k]:=a[na-k]. Readln(a[na]).nmax. Type mang=Array[1. nb:=0.' = '). na:=na-1.spt] Of Integer. Readln(b[nb]). For k:=spt Downto spt-nmax Do . tam:=0. Writeln.b.na. Writeln.

Writeln. tam:=(a[k]+b[k]+tam) Div 10.' '). For k:=0 To na-1 Do a[spt-k]:=a[na-k]. Readln End. Writeln('KET QUA CONG 2 SO NGUYEN').tam:Integer.spt] Of Integer. ClrScr.' = '). Var tam1. Writeln. For k:=1 to spt-na Do a[k]:=0. Write('*So thu nhat: '). Until a[na]=-1.j. End.b.kq:Mang. Uses Crt. . i. {---------------------------} Procedure Nhap(Var a:mang.tam2. Begin na:=0. Writeln. Var k:Integer. 22/Nhân 2 s nguyên: CODE (Ch n t t c ) Program Nhan_so. Write('-Chu so thu: '. na:=na-1. Writeln('------------------------').k..c. For k:=spt-na+1 To spt Do Write(a[k]. End. Const spt=900. Write('*Tong = '). Type mang=Array[1.na. Write('*So thu hai : ').na. Var na:Integer).' '). Repeat na:=na+1.nb. For k:=spt-nb+1 To spt Do Write(b[k].' ').k:Integer. {---------------------------} Procedure Cong(a:mang.Begin kq[k]:=(a[k]+b[k]+tam) Mod 10. For k:=Spt-nmax To spt Do Write(kq[k]. Readln(a[na]). Var b:mang). Writeln(' Bam phim <Enter> de ket thuc '). Var a.

For k:=spt-nb+1 To spt Do Write(b[k]. Write('*So thu hai : '). Writeln('NHAN 2 SO NGUYEN'). {---------------------------} BEGIN ClrScr. For k:=spt-na+1 To spt Do Write(a[k]. For k:=1 To spt Do kq[k]:=0. Writeln('-----------------------'). Writeln.kq) End. Readln END. ClrScr. 23/Ma tr n vuông 10x10 ph n t : . Write('*So thu nhat: '). Nhap(b. Writeln('+SO THU HAI (-1 de ket thuc) '). For j:=spt Downto spt-nb Do Begin For k:=1 to spt Do c[k]:=0.' '). For k:= spt Downto 1 Do Begin tam2:=(a[k]+b[k]+tam1) Div 10. Writeln. End. Writeln('----------------'). For i:=spt Downto spt-na Do Begin c[j+i-spt]:=(b[j]*a[i]+tam) Mod 10. Writeln('+SO THU NHAT (-1 de ket thuc) '). Writeln('KET QUA NHAN 2 SO NGUYEN'). Writeln. tam:=0.nb). tam:=(b[j]*a[i]+tam) Div 10. ClrScr. End. For k:=Spt-(na+nb)+1 To spt Do Write(kq[k]. Write('*Tich = '). Nhap(a.Begin tam1:=0. End. Writeln(' Bam phim <Enter> de ket thuc ').' '). b[k]:=(a[k]+b[k]+tam1) Mod 10. tam1:=tam2. Cong(c. Writeln.na). Writeln.' ').

j. solan:=0. Var a:Array[1. Writeln(#10) End.CODE (Ch n t t c ) Program Ma_tran_vuong.4.j).. Writeln('-----------------------------'). i. 24/Tìm m t s trong m ng: CODE (Ch n t t c ) Program Tim_so.60. . For i:= 1 To 10 Do Begin For j:=1 To 10 Do Begin If i=j Then a[i. Readln(so).j] Then Begin solan:=solan+1.j]:=0. Writeln('+Lan: '. End.j:Integer. Var a:Array[1.j]:=i Else a[i.so.'.' cot: '.. Write('-So muon tim: ').25). Writeln. Writeln. i.. Begin Writeln('TIM MOT SO TRONG MANG').' tai hang: '. End.i.5. End.j.6] Of Integer. For i:=1 To 4 Do For j:=1 To 6 Do If so=a[i. Writeln.. Writeln(' Bam phim <Enter> de ket thuc '). For i:=1 To 4 Do For j:=1 to 6 Do Begin Write('-Phan tu A['.j]:5).j]).10] Of Integer. Uses Crt.'. Writeln('---------------------').1. Window(10.i. Readln End.solan:Integer. Write(a[i. Readln(a[i. Begin Writeln('MA TRAN VUONG 10 x 10 PHAN TU'). 1.solan.10.']= '). ClrScr.

Writeln('X= '. Writeln. Dty:=a[1.2]*c[1]. {Giai he phuong trinh} Dt:= a[1. Writeln('Y= '.dty:Real. For i:=1 to 2 Do Begin Write('+Phan tu C['. Writeln('-Nhap cac he so C cua he phuong trinh: '). End. End.i.i.2] Of Real. y:=Dty / Dt.'. x. End Else Begin If (Dtx=0) And (Dty=0) Then Writeln(#7. Var A:Array[1.1].#7. i. For i:=1 To 4 Do Begin For j:=1 To 6 Do Write(a[i.#7. Writeln('+Tong so lan xuat hien la: '. Begin Writeln('GIAI HE PT TUYEN TINH 2 AN'). {Dt: Dinh thuc} Dtx:=c[1]*a[2.j]:8).j.1]*a[2..'.dtx. Readln End.']= ').1]*c[2]-a[1. For i:=1 to 2 Do For j:=1 To 2 Do Begin Write('+Phan tu A['. Writeln. Writeln('-Nhap cac he so A cua he phuong trinh: '). Readln(c[i]). 1. End.2]-a[1.Writeln.dt.j:Integer. If Dt <> 0 Then Begin x:=Dtx / Dt.' Co vo so nghiem') Else Writeln(#7.2] Of Real... Writeln('--------------------------'). .1]. Writeln.j]).y).'Vo nghiem').y. C:Array[1.solan).2.']= '). 25/Gi i h phu ng trình tuy n tính 2 n: CODE (Ch n t t c ) Program Giai_he_PT_tuyen_tinh.#7. Readln(a[i.x). Writeln.2]-c[2]*a[2.#7.2]*a[2.

Var A.'.cot1. Writeln('MA TRAN A:'). Begin Writeln('NHAN MA TRAN'). Hang1:=m. Writeln. For i:=1 To Hang1 Do For j:=1 To n Do Begin c[i. Writeln('MA TRAN B:'). hang1.B. 26/Nhân ma tr n: CODE (Ch n t t c ) Program Nhan_ma_tran.j]).q:Integer. For i:=1 To m Do For j:=1 To n Do Begin Write('+Phan tu A['. Write('-So hang = '). End. For i:=1 to hang1 Do Begin For j:= 1 To n Do . For q:=1 To Cot1 Do c[i.i. Readln(n). Writeln.j. For i:=1 To m Do For j:=1 To n Do Begin Write('+Phan tu B['. Writeln('------------').n. Readln(m).j. End.j] + a[i.' = ').m.'. Readln(a[i. Readln(b[i. Readln(m). Writeln.1.j]). Const Max=10. Type Matran=Array[1.j]:=0.C:Matran..' = '). Readln(n).End. End.j]. Cot1:=m.'.'.j]:= c[i. Writeln(' Readln End. Bam phim <Enter> de ket thuc ')..q] * b[q.Max] Of Integer. Write('-So hang = ').i. Write('-So cot = '). Write('-So cot = ').Max.i.j.

If UpCase(Ch)='C' Then Begin Delete(St.St[i]. End. Ch:Char. While i <= l Do Begin i:=i+1. Writeln(' Chuoi con lai: '.l. Writeln.1. Writeln(' Sau khi xoa ky tu trung nhau').' ky tu'). 28/Tìm chu i 2 xu t hi n trong chu i 1: CODE (Ch n t t c ) Program Tim_chuoi. Readln(St). Writeln(' Bam phim <Enter> de ket thuc'). Readln(Ch). If St[i]=St[i . Var St. 27/Tìm và xóa các kí t trùng nhau trong chu i: CODE (Ch n t t c ) Program Tim_Xoa. Write('-Nhap mot chuoi: ').1] Then Begin Writeln('+Ky tu thu: '.St1. End.j]):8).i. Readln End. Readln End. Writeln. Writeln('+Chuoi ban dau : '.St1:String. Var St1. Writeln. .' gom: '. End. End.' la: '.' co: '.l1:Byte. l:=Length(St). i:= i .i:2. Write('Ban co muon xoa ky tu nay khong (c/k)'). l1:=Length(St).l:2.St. i:=1. St1:=St.' bi trung lap').Write((c[i. Writeln. i.' ky tu'). Writeln(' -----------------').1). Begin Writeln('TIM VA XOA CAC KY TU TRUNG NHAU TRONG CHUOI').St2:String.l1:2.

i. Readln(St). i:=i-1. Write('-Chuoi thu hai : '). L1:Write('-Nhap so La ma: '). Readln End.Length(St2)) Then sl:=sl+1. Begin Writeln('TIM CHUOI HAI XUAT HIEN TRONG CHUOI MOT'). i. Var St:String.sl:Integer. . i:=Length(St). 'X':If (i > 1) And (St[i-1] = 'I') Then Begin So:=So+9. While i > 0 Do Case St[i] Of 'I':Begin So:=So+1.' lan trong chuoi 1'). i:=i-1. i:=i-2. 29/ i s La mã ra s th p phân: CODE (Ch n t t c ) Program So_La_Ma. End. End. Writeln. Write('-Chuoi thu nhat: ').i. 'V':If (i > 1) And (St[i-1] = 'I') Then Begin So:=So+4. sl:=0. End Else Begin So:=So+5. So:=0. Readln(St1).So:Integer. Writeln(' Bam phim <Enter> de ket thuc'). Writeln(' --------------'). Writeln. tiep:Char. Writeln('+Chuoi thu 2 xuat hien: '. Label l1. Writeln.sl:2. Writeln. Writeln(' ------------'). Readln(St2). For i:=1 To Length(St1) Do If St2 = Copy(St1. Begin Writeln('DOI SO LA MA RA SO THAP PHAN').

So). i:=i-2. Writeln('+So La ma : '. Writeln. End. i:=i-1. End Else Begin So:=So+100. End Else Begin So:=So+500.i:=i-2. End. Readln(tiep). i:=i-1. i:=i-2. End. Write('-Tiep tuc nua khong (c/k) '). End Else Begin So:=So+1000. End. End.St). i:=i-2. = 'X') Then = 'X') Then = 'C') Then = 'C') Then End. i:=i-1. i:=i-1. 'M':If (i > 1) And (St[i-1] Begin So:=So+900. If UpCase(tiep)='C' Then Goto l1. i:=i-1. End Else Begin So:=So+10. Writeln('+Doi ra thap phan: '. 'C':If (i > 1) And (St[i-1] Begin So:=So+90. . End. End Else Begin So:=So+50. 'D':If (i > 1) And (St[i-1] Begin So:=So+400. i:=i-2. 'L':If (i > 1) And (St[i-1] Begin So:=So+40.

xin nhap lai:').So:8:2) Else Writeln(' +Khong phai so. If (n >=97) And (n<=122) then Begin n:=n+k. i. If Dung = 0 Then Writeln(' +Ban da nhap mot so: '. k:Integer. If UpCase(Tiep)='C' Then Goto tt. If n > 122 Then n:=(n Mod 122) + 96. For i:= 1 To Length(St) Do Begin n:=Ord(St[i]). End. St[i]:=Chr(n). Var St:String. Readln(St). Val(St. So:Real.n:Integer. tt:Write('-Nhap mot so: '). Writeln(' -----------'). Write('-Co tiep tuc khong (C/K) '). 31/Chu ng trình mã hóa: CODE (Ch n t t c ) Program Ma_hoa. k:=k Mod 26. . Label tt. Readln(St). Write('-Nhap ma so k: '). Readln(Tiep). Begin Writeln('CHUONG TRINH MA HOA'). tiep:Char. Dung:Integer.30/Ki m tra s nh p vào: CODE (Ch n t t c ) Program Kiem_tra_so.Dung). Readln(k). Until Dung = 0. Writeln(' -----------'). Begin Repeat Writeln('KIEM TRA SO NHAP VAO').So. Writeln. Var St:String. Write('-Nhap chuoi: '). End.

Until Length(St)=0. i:Integer.End. Repeat While (St[1] =' ') And (Length(St) <> 0) Do Delete(St.1). Writeln(' --------------').St2) = 0 Then .St2:String. Writeln. Writeln.1). Delete(St. Var St1. Write('-Nhap chuoi 2: '). 32/Ng t t ng t trong câu: CODE (Ch n t t c ) Program Ngat_tu. Readln(St2). Var St:String. Readln(St1). Dung:=False. While (St[1] <> ' ') And (Length(St) <>0) Do Begin Write(St[1]). Writeln. Write('-Nhap mot cau: '). Readln End. Writeln. 33/Ki m tra kí t trùng c a 2 chu i: CODE (Ch n t t c ) Program Cung_Ky_Tu. Writeln(' --------------'). Dung:Boolean.St). Writeln(' Bam phim <Enter> de ket thuc'). End. Readln End. For i:= 1 To Length(St1) Do If Pos(St1[i].1. Writeln('+Sau khi ma hoa: '. Writeln. Write('-Nhap chuoi 1: ').1. If Length(St1)=Length(St2) Then Begin Dung:=True. Begin Writeln('NGAT TUNG TU TRONG CAU'). Begin Writeln('KIEM TRA KY TU TRUNG CUA 2 CHUOI'). Readln(St).

Writeln. . Var So. Readln(So). 34/Ki m tra chu i CODE (Ch n t t c ) i x ng: Program Chuoi_Doi_Xung.St2). St:=' '. So1:=So. Write('-Nhap so nguyen: '). St:String. So:=So Mod 1000. Readln End. Var St:String. Writeln.So1. End. Write('-Nhap chuoi: '). For i:=1 To (l Div 2) Do If St[i] <> St[l-i+1] Then Dung:=False.i:Integer. If Dung Then Writeln('+Hai chuoi co cung cac ky tu') Else Writeln('+Hai chuoi co cac ky tu khac nhau').Pos(St1[i]. For i:=1 To (so Div 1000) Do St:=St+'M'. 35/ i s th p phân ra s la mã: CODE (Ch n t t c ) Program So_La_Ma. Begin Writeln('KIEM TRA CHUOI DOI XUNG').i:Integer. Readln End. l:=Length(St). If Dung Then Writeln('+Chuoi nay doi xung') Else Writeln('+Chuoi nay khong doi xung'). Writeln(' -------------'). l. Begin Writeln('DOI SO THAP PHAN SANG SO LA MA'). Dung:Boolean.Dung:=False Else Delete(St2.1). Dung:=True. Readln(St). Writeln(' ------------').

So:=So-4. For i:=1 To (so Div 100) Do St:=St+'C'. . So:=So-9. So:=So-500. End Else If So >=5 Then Begin St:=St+'V'. So:=So-900. For i:=1 To (so Div 10) Do St:=St+'X'. End Else If So >=40 Then Begin St:=St+'XL'. If So >= 90 Then Begin St:=St+'XC'. End. End Else If So >=500 Then Begin St:=St+'I'. End Else If So >=4 Then Begin St:=St+'IV'.If So >= 900 Then Begin St:=St+'CM'. So:=So-5. End. If So >= 9 Then Begin St:=St+'IX'. End Else If So >=50 Then Begin St:=St+'L'. So:=So Mod 100. So:=So-50. End. So:=So-40. So:=So-400. So:=So Mod 10. So:=So-90. End Else If So >=400 Then Begin St:=St+'CD'.

Writeln. Writeln. Readln(N). Writeln('+So La ma : '. Readln End. Repeat Write('-Cho biet so phan tu: '). For i:=1 To N Do Begin Write('+Phan tu thu: '. Writeln. Writeln.' = '). Writeln('------------'). Writeln('+So thap phan: '. Uses Crt. Writeln('--------------------'). Readln End.St). Type Mang=Array[1.n:Integer.So1). For i:=1 To N Do Write(a[i]:4:1. Var i. Writeln(' Bam phim <Enter> de ket thuc'). 36/Mãng s th c: CODE (Ch n t t c ) Program Mang_so_thuc. Writeln. Writeln.' '). Const Max = 100. Writeln('IN CAC DOI SO CUA CAC PHAN TU MANG').For i:=1 To So Do St:=St+'I'. Writeln('IN THEO THU TU NGUOC').Max] Of Real.' '). Until N <= Max. Writeln. Begin Writeln('MANG SO THUC'). 37/T ng tích ma tr n: CODE (Ch n t t c ) Program Tong_Tich_Ma_tran. A:mang. For i:=N Downto 1 Do Write(a[i]:4:1. End. Readln(a[i]). ..i. Writeln. Writeln('----------------------------------').

{*****************************} BEGIN Nhap(a. {*****************************} Procedure Xuat(m:Matran.'. Writeln.j]:=0.Ten). {*****************************} Procedure Nhap(Var m:Matran. Writeln('MA TRAN TONG').j]). End.6).3] Of Integer.j]). For k:=1 To 3 Do d[i.']= '). For i:=1 to 3 Do For j:=1 To 3 Do Begin d[i. GotoXY(26.j].Ten). For i:=1 To 3 Do For j:=1 To 3 Do c[i.c. Write(Ten. End.k]*b[k.b.'['. Write('-Nhap ma tran: '.10+2*j).d:Matran. For i:=1 To 3 Do For j:=1 To 3 Do Begin GotoXY(20*i-8.i. Nhap(b.'.j]+d[i.j. Var a. Begin ClrScr. End.. For i:=1 To 3 Do For j:=1 to 3 Do Begin GotoXY(20*i-8.'A').j]. Writeln. Readln(m[i. GotoXY(26.. Repeat Ch:=Readkey.'. If Ch=#0 then Ch:=Readkey. Begin ClrScr.1. Write(Ten.3.k:Byte. Ten:Char).'B').25). .m[i.'C'). End.j]:=a[i. End.j.10+2*j).']= '.j]+b[i. GotoXY(10. Xuat(c.i.Type Matran=array[1. Ch:Char.6). Write('Bam phim <Esc> de xem ma tran tich').j]:=a[i. Ten:Char). i. Write('CAC PHAN TU CUA MA TRAN: '.'.'['.

Writeln('MA TRAN TICH= ').j.. a[j]:=tam. Const spt=10.'D'). For i:= 1 To Max Do Begin Write('-Phan tu A['. For i:=1 to Max-1 Do For j:= i+1 To Max Do Begin If a[i] > a[j] Then Begin tam:=a[i]. END. Const Max=10. Readln(a[i]).k. Begin Writeln('SAP XEP MANG BANG GIAI THUAT CHEN'). Readln End. Begin Writeln('SAP XEP MANG TANG DAN').Max] Of Integer. 39/S p x p m ng b ng gi i thu t chèn: CODE (Ch n t t c ) Program Gt_Chen. End. Repeat Until KeyPressed.spt] Of Integer.']= '). Writeln('+Mang sau khi sap xep:'). End. Var a:array[1.Until Ch=#27.tam:Integer.' ').j. Writeln.i. i. i. Writeln. Writeln('---------------------'). End. Writeln.tam:Integer. For i:=1 To Max Do Write(a[i]. Xuat(d. a[i]:=a[j].. 38/S p x p m ng t ng d n: CODE (Ch n t t c ) Program Mang_tang. . Var a:Array[1. Writeln.

Writeln('---------------------------------'). Readln End. Var a:array[1.j:Integer. a[j]:=tam. min.i. While a[j] < a[i] Do j:=j+1. tam:=a[i]. a[vitri]:=a[i].spt] Of Integer. Readln(a[i]).vitri.']= '). End. For i:=1 To spt Do Begin Write('-Phan tu A['. 40/S p x p m ng b ng gi i thu t ch n: CODE (Ch n t t c ) Program Gt_Chon. Readln(a[i]). Writeln(' Bam phim <Enter> de ket thuc ').']= '). For k:=i Downto j+1 Do a[k]:=a[k-1]. End. vitri:=spt. Writeln('Mang sau khi sap xep:'). vitri:=j. For i:=2 To spt Do If a[i] < a[i-1] Then Begin j:=1.i. . For i:=1 To spt Do Begin min:=a[spt]. For j:=i To spt Do If a[j] < min Then Begin min:=a[j].Writeln('---------------------------------'). End.i. For i:=1 To spt Do Write(a[i]:6). For i:=1 To spt Do Begin Write('-Phan tu A['. Begin Writeln('SAP XEP MANG BANG GIAI THUAT CHON'). End. Const spt=10. Writeln.. Writeln. Writeln. Writeln.

42/Gi i thu t tìm ki m tuy n tính: CODE (Ch n t t c ) Program Tim_Tuyen_Tinh. Var . Writeln. Readln(a[i]). For i:=1 To spt Do Begin Write('-Phan tu A['. End.']= '). Const N=10.a[i]:=min.spt] Of Integer. Writeln('Mang sau khi sap xep:'). Begin Writeln('SAP XEP MANG BANG GIAI THUAT NOI BOT'). End. Writeln('-----------------------------------'). Writeln(' Bam phim <Enter> de ket thuc '). End. i. a[j-1]:=tam. Writeln.tam:Integer. Writeln. Var a:array[1. 41/S p x p m ng b ng gi i thu t n i b t: CODE (Ch n t t c ) Program Gt_Noi_bot. Writeln. Const spt=10. Writeln. Readln End. For i:=1 To spt-1 Do For j:= spt Downto i+1 Do If a[j] < a[j-1] Then Begin tam:=a[j].i. For i:=1 To spt Do Write(a[i]:6). a[j]:=a[j-1]. Writeln('Mang sau khi sap xep:'). For i:=1 To spt Do Write(a[i]:6). Readln End.j.. Writeln(' Bam phim <Enter> de ket thuc ').

For i:=1 To N Do Begin Write('-Phan tu A['.']= '). 43/Gi i thu t tìm ki m nh phân: CODE (Ch n t t c ) Program Tim_Nhi_Phan. Writeln('----------------------------'). Begin Writeln('GIAI THUAT TIM KIEM TUYEN TINH').']= '). While vt2 >= vt1 Do Begin i:=Trunc((vt1+vt2) Div 2). If i <= N Then Writeln('+Tim thay o vi tri thu: '.i) Else Writeln('+Khong tim thay'). Write('-So can tim: '). Writeln. so. Begin Writeln('GIAI THUAT TIM KIEM NHI PHAN'). Writeln.N] Of Integer. Readln(a[i]). Write('-So can tim: ').i. Writeln. Var a:array[1. so. Writeln. Writeln. While (i <=N) And (a[i] <> so) Do i:=i+1.a:array[1.N] Of Integer. If so > a[i] Then vt1:=i+1 Else If so < a[i] Then .. Readln(a[i]).i:Integer. Const N=10. Writeln(' Bam phim <Enter> de ket thuc ').i:Integer. Readln(so).vt1.vt2.i. vt1:=1. For i:=1 To N Do Begin Write('-Phan tu A['.. Readln End. i:=1. End. vt2:=n. Writeln('------------------------------'). Readln(so). End.

Write('-Mang con lai: '). While i <= N Do Begin j:=1. If j < i Then Begin For k:=i to n-1 Do a[k]:= a[k+1]. End. i:=2. Writeln. Begin Writeln('XOA BO CAC SO TRUNG NHAU').. End Else i:=i+1.k. Readln(a[i]).Max] Of Integer.']= '). Readln End. For i:=1 to n Do Write(a[i]:8). End. Writeln('------------------------'). If vt2 = -1 Then Writeln('+Tim thay o vi tri thu: '. While a[j] <> a[i] Do j:=j+1. End.n:Integer. Writeln.j. Const Max=100. Writeln(' Bam phim <Enter> de ket thuc ').vt2:=i-1 Else vt2:=-1. Var a:Array[1. i. Writeln. Writeln(' Bam phim <Enter> de ket thuc '). Write('-Nhap so phan tu mang: '). Readln(n). For i:=1 To N Do Begin Write('-Phan tu A['. Writeln. 44/Xóa b các s trùng nhau: CODE (Ch n t t c ) Program Bo_so_trung. . n:=n-1.i.i) Else Writeln('+Khong tim thay'). Readln End.

8. max:=a[1]. Const a:Array[1. a:Array[1.'le thanh ton'. tong:=a[1].'chu van an'.max:Integer. max:=max-a[i].3.12. 46/Ch hoa: CODE (Ch n t t c ) Program Chu_hoa.j:Byte. Uses Crt. Until max=0. Readln End. n:=i. i:=i+1. Const k=10. Writeln(' Bam phim <Enter> de ket thuc '). Begin Vt:=1.45/Dãy con: CODE (Ch n t t c ) Program Day_con. 'nguyen hue'.6. Writeln('-Day con la: ').'dinh tien hoang'.2.'le loi'. vt:=n. tong:=a[i]. 'nguyen cong tru'.tong:Integer.7.'le lai'.k] Of Integer=(1.3).10] Of String[24]=('nguyen trung truc'. End. n:=1.29..'mac dinh chi'). n.. Writeln. {-------------------------} . Repeat Write(a[i]:6).'tran hung dao'. End. Var k. Var i:Integer.10. vt. For i:=2 To k Do Begin If (a[i] > a[i-1]) Then tong:=tong+a[i]. End. i:=vt. If (a[i] < a[i-1]) Or (i=k) Then Begin If tong > max Then Begin max:=tong.

. Writeln(' Bam phim <Enter> de ket thuc '). Write(a[k]:-24).j]:=0.Procedure ChuHoa(x.j]. Writeln.k).. For i:=1 To n Do a[i.y:Byte. End.a[k]) End. Begin ClrScr. Writeln. Readln End.1]:=1.y). For k:=1 To 10 Do Begin GotoXY(5.n] Of Integer. Var a:Array[1.j]:=a[i-1. a:String). For i:=1 To n Do Begin For j:=1 To i Do Write(a[i. Readln End. Writeln. Write(UpCase(a[k])). Writeln(' Bam phim <Enter> de ket thuc '). . 1.k. Const n=10. End. For j:=1 To n Do a[1. 47/Tam giác Pascal: CODE (Ch n t t c ) Program Tg_Pascal.n. i.j]:4).j:Integer. ChuHoa(5. Begin Writeln('TAM GIAC PASCAL'). Begin For k:=1 To length(a) Do If (k=1) Or ((a[k-1]=' ') And (a[k]<>' ')) Then Begin GotoXY(x+k-1. Writeln. For i:=2 To n Do For j:=2 To n Do a[i. End. Writeln('---------------').j-1]+a[i-1. Var k:Byte.

j]=a[i1.j.. For i:=1 To n Do For j:=1 To i Do Begin For i1:= i+1 To n Do For j1:=1 To j-1 Do If a[i.j:Byte.' + '. Const n=15.hang:Byte.' ^3 '.i1. For i:=1 To n Do For j:=1 To n Do a[i.' ^3 '. Writeln('----------').. Begin cot:=1.. Writeln. 1. a[i.48/Phân tích s nguyên du ng nh nh t: CODE (Ch n t t c ) Program Phan_tich.' = '.j1:Integer. Var a:Array[1. Writeln(' Bam phim <Enter> de ket thuc ').n] Of Longint.i. Begin Writeln('PHAN TICH SO NGUYEN DUONG NHO NHAT'). Type cc1=Array[1. i1.. cc2=Array[6. End.' ^3 '.' + '. hang:=3.10.j]. Readln End. Var i. Uses Crt. Procedure In1.5.j1] Then Writeln(a[i. For i:=1 To 5 Do For j:=1 To 10 Do Begin GotoXY(cot.10] Of Byte.j1.' ^3')..j. Writeln('----------------------------------').j]:=i*i*i + j*j*j.. i.10] Of Byte. Writeln. 1. Writeln('IN KET QUA').' = '.n. Var a:cc1.j]:=i * j. . cot. 1.hang). 49/B ng c u chu ng: CODE (Ch n t t c ) Program Cuu_Chuong. Writeln.

hang:=hang+1.j:2. Writeln(i:2. BEGIN ClrScr. Writeln(' Readln END. End. End.. Procedure In2.a[i. . Textcolor(LightGreen). Textcolor(LightBlue). Textcolor(LightMagenta). Textcolor(Cyan). Begin cot:=1. End.' lan '. If hang > 23 Then Begin hang:=14.' ='. Uses Crt. -------------------------------------------').j]:3. cot:=cot+15. End. {----------------------------} Procedure Tao.j:2. Writeln(' Writeln(' In1. cot. ---------------'). a[i. Bam phim <Enter> de ket thuc').' ='. BANG CUU CHUONG').'|').1000] Of Integer. 50/Tìm 2 ph n t liên ti p trong b ng X: CODE (Ch n t t c ) Program Tim_PT_Mang.j]:=i * j.hang). cot:=cot+15. Writeln(i:2. Var a:cc2. End.'|'). hang:=hang+1. Var a:Array[1.hang:Byte.' lan '.TextColor(Yellow). For i:=6 To 10 Do For j:=1 To 10 Do Begin GotoXY(cot. If hang > 12 Then Begin hang:=3. hang:=14. End.j]:3. Writeln(' In2.a[i.

While ±.X) Else Writeln('Khong co 2 phan tu nao bang: '.Ph n 1 [Bài T p Pascal Hay] C U TRÚC D LI U KI U FILE .Có áp Án [Bài T p Pascal Hay] VÒNG L P XÁC NH VÀ KHÔNG XÁC NH (For . . Tao. Var k. End. End. For k:=1 To 999 Do Begin If a[k] +a[k+1] = X Then Writeln('a['. End. Writeln.'] + a['.CH NG I Th Vi n Các D ng Bài T p Pascal c a Tin H c 11 .Var k:Integer.']= '.X). END. For k:=1 To 100 Do a[k]:=Random(100). Writeln('-------------------------------------').Ph n 2 [Bài T p Pascal Hay] C U TRÚC D LI U KI U M NG . Khách vi ng th m ã y y y y y y y y y y c qua nh ng bài này cùng chuyên m c ch a?: Các Bài T p Pascal l p 11 . Tim..CH NG III Th Vi n Các D ng Bài T p Pascal c a Tin H c 11 . BEGIN Writeln('TIM 2 PHAN TU LIEN TIEP BANG GIA TRI X'). Readln(x).CH NG II [Bài T p Pascal] XÂU KÝ T (STRING) .Có áp Án Các Bài T p Pascal l p 11 . Writeln. {----------------------------} Procedure Tim.Có áp Án Các Bài T p Pascal l p 11 . Begin Write('-Nhap gia tri X= '). Readln.Có áp Án [Bài T p Pascal Hay] D LI U KI U T P .K+1. Writeln(' Bam phim <Enter> de ket thuc '). Begin Randomize..K.x:Integer.

You're Reading a Free Preview

Descarga
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->