1. Trang chủ
  2. » Thể loại khác

al của Tin Học 11 docx

116 272 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 116
Dung lượng 1,2 MB

Nội dung

1. al của Tin Học 11 - Phần 1  Giáo trình lập trình Pascal nâng cao -Mediafire 25/11/2011  CD-ROM Giáo trình Pascal 07/02/2013 1/Sắp Xếp Theo Tên: Code: 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: 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: 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: 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 First := Newp Else Last^.Next := Newp; Last :=Newp; Last^.Next := Nil; Ch := ReadKey; Until Ch = #27; ClrScr; Writeln('QUAN LY THU VIEN'); Writeln(' '); While First <> Nil Do With First^ Do Begin Writeln('-Ten sach: ',TenSach); Writeln('-Tac gia : ',TacGia); Writeln('-Nam Xuat ban: ',Namxb); Writeln('-Nguoi muon : ',NguoiMuon); First := Next; End; Writeln; Writeln('+Tong so sach: ',Ds); Writeln('+So sach cho muon: ',Dm); Release(HeapTop); Writeln; Write(' Bam <Esc> de thoat'); Readln END. 5/Hồ Sơ Nhân Viên: Code: Program Ho_So_Nhan_Vien; Uses Crt; TYPE ConTro = ^HoSo; HoSo = RECORD HoTen : String[24]; Tuoi : Integer; Luong : LongInt; Next : ConTro; End; VAR First, Last, Newp : ConTro; Hoten1, Hoten2 : String[24]; i,TuoiMax,TuoiMin : Integer; LuongMax, LuongMin,LuongTb : LongInt; Ch : Char; HeapTop :^Integer; Begin ClrScr; Writeln('HO SO NHAN VIEN'); Writeln(' '); Writeln; GoToXY(5,25); Write('Bam <Enter> de tiep tuc, bam <Esc> de thoat '); Window(1,2,80,25); First :=Nil; Mark(HeapTop); i := 0; Repeat i := i + 1; New(Newp); With Newp^ Do Begin Write('-Ho ten nhan vien thu: ',i:2,' la= '); Readln(HoTen); Write('-Tuoi = '); Readln(Tuoi); Write('-Bac luong = '); Readln(Luong); TuoiMax := Tuoi; TuoiMin := Tuoi; LuongMax := Luong; LuongMin := Luong; HoTen1 := HoTen; HoTen2 := HoTen; End; If First = Nil Then First := Newp Else Last^.Next := Newp; Last := Newp; Last^.Next := Nil; Ch := ReadKey; Until Ch = #27; Writeln; While First <> Nil Do With First^ Do Begin If Tuoi > TuoiMax Then TuoiMax := Tuoi Else If Tuoi < TuoiMin Then TuoiMin := Tuoi; If Luong > LuongMax Then Begin LuongMax := Luong; HoTen1 := HoTen; End Else If Luong < LuongMin Then Begin LuongMin := Luong; HoTen2 := HoTen; End; First := Next; End; Writeln; Writeln('Nhan vien co tuoi lon nhat la: ',TuoiMax); Writeln('Nhan vien co tuoi nho nhat la:',TuoiMin); Writeln('Nhan vien: ',HoTen1,' ,co bac luong lon nhat: ',LuongMax:10); Writeln('+Nhan vien: ',HoTen2,' ,co bac luong nho nhat: ',LuongMin:10); Release(HeapTop); Writeln; Write(' Bam <Enter> de ket thuc '); Readln End. 6/Tính điểm xếp hạng: Code: Program Tinh_Diem_Xep_Hang; TYPE ConTro = ^Lop; Lop = RECORD HoTen : String[24]; NamSinh : Integer; Tb1,Tb2,Tb : Real; End; VAR Hs : Array[1 50] Of lop; i,j,n,Hang: Integer; Tam : ConTro; Begin Writeln('TINH DIEM VA XEP HANG);'); Writeln('Giai thuat noi Buble'); Writeln(' '); Writeln; New(Tam); 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 hoc ky 1: '); Readln(Tb1); Write(' +Diem trung binh hoc ky 2: '); Readln(Tb2); Tb :=(Tb1 + Tb2)/2; Writeln; End; For i := 1 To N-1 Do For j := 1 To N-i Do If Hs[j].Tb < Hs[j+1].Tb Then Begin Tam^ := Hs[j]; Hs[j] := Hs[j+1]; Hs[j+1] := Tam^; End; Writeln; Writeln(' DANH SACH XEP HANG'); Writeln; Hang := 1; For i := 1 To N Do Begin If (i > 1) And (Hs[i].Tb <> Hs[i-1].Tb) Then Hang := i; Writeln(' .Hoc sinh : ',Hs[i].HoTen); Writeln(' .Nam sinh : ',Hs[i].NamSinh); Writeln(' .Diem trung binh ca nam : ',Hs[i].Tb:5:2); Writeln(' .Xep hang ca nam : ',Hang); End; Readln End. 7/Hoán vị chuỗi: Code: Program Hoan_Vi_Chuoi; Uses Crt; VAR Chuoi1,Chuoi2,Tam :^String; Begin ClrScr; Writeln('HOAN VI 2 CON TRO THAY CHO HOAN VI NOI DUNG'); Writeln(' '); Writeln; New(Chuoi1); New(Chuoi2); Chuoi1^ := 'Giao trinh Turbo Pascal 7.0'; Chuoi2^ := 'Giao trinh FoxPro 2.6'; Writeln; Writeln('NOI DUNG BAN DAU CUA 2 CHUOI'); Writeln(' '); Writeln; Writeln('-Chuoi thu nhat: ',Chuoi1^); Writeln('-Chuoi thu hai : ',Chuoi2^); Writeln; Writeln('NOI DUNG SAU KHI HOAN VI 2 CON TRO'); Writeln(' '); Writeln; Tam := Chuoi1; Chuoi1 := Chuoi2; Chuoi2 := Tam; Writeln('-Chuoi thu nhat: ',Chuoi1^); Writeln('-Chuoi thu hai : ',Chuoi2^); Dispose(Chuoi1); Dispose(Chuoi2); Writeln; Write(' Bam <Enter> . . . '); Readln; End. 8/Tách danh sách chẳn lẻ: Code: Program Tach_Danh_Sach_Chan_Le; Uses Crt; TYPE Mang = Array[1 100] Of Integer; VAR i,j,k,n : Integer; a,b,c : Mang; Begin ClrScr; Writeln(' NHAP DANH SACH'); Writeln(' '); Write('-So phan tu: '); Readln(n); For i := 1 To n Do Begin Write('-Phan tu thu: ',i:2,' = '); Readln(a[i]); End; Writeln; Writeln('TACH THANH 2 DANH SACH'); Writeln(' '); Writeln; j := 1; k := 1; For i := 1 To n Do If Odd(a[i]) Then Begin b[j] := a[i]; j := j + 1; End Else Begin c[k] :=a[i]; k := k + 1; End; Writeln; Writeln(' -Danh sach thu nhat ( so le ) '); Writeln; For i := 1 To j-1 Do Write(b[i],' '); Writeln; Writeln; Writeln(' -Danh sach thu hai ( so chan ) '); Writeln; For i := 1 To k-1 Do Write(c[i],' '); Writeln; Write(' Bam <Enter> . . . '); Readln End. 9/Đảo ngược danh sách: Code: Program Dao_Nguoc_Danh_Sach; Uses Crt; TYPE ConTro = ^Nut; Nut = RECORD So : Integer; Next : ConTro; End; VAR Nut1,Tam1,Tam2 : ConTro; Ch : Char; BEGIN ClrScr; Writeln(' DAO NGUOC DANH SACH'); Writeln(' '); Nut1 := Nil; Repeat New(Tam1); Write('-Nhap so: '); Readln(Tam1^.So); Tam1^.Next := Nut1; Nut1 := Tam1; Write(' Nhap nua khong ? (c/k) '); Readln(Ch); Until UpCase(Ch)= 'K'; Tam1 := Nut1; Nut1 := Nil; Repeat Tam2 := Tam1^.Next; Tam1^.Next := Nut1; Nut1 := Tam1; Tam1 := Tam2; Until Tam1 = Nil; Writeln('Sau khi dao: '); Tam1 := Nut1; While Tam1 <> Nil Do Begin Write(Tam1^.So:6); Tam1 := Tam1^.Next; End; Writeln; Write(' Bam <Enter> . . . '); Readln END. 10/Ghép Chuỗi: Code: Program Ghep_Chuoi; Uses Crt; TYPE ConTro = ^Nut; Nut = RECORD Kt : Char; Next : ConTro; End; VAR Dau1,Cuoi1 : ConTro; Dau2,Cuoi2 : ConTro; Tam : ConTro; Ch : Char; i : Integer; BEGIN ClrScr; Writeln('CHUOI THU NHAT'); Writeln(' '); Writeln; i := 0; Repeat i := i + 1; New(Tam); Write('-Ky tu thu: ',i:2,' : '); Readln(Tam^.Kt); If i = 1 Then Begin Dau1 := Tam; Cuoi1 := Tam; End Else Begin Cuoi1^.Next := Tam; Cuoi1 := Tam; End; Write('Nhap nua khong ? (c/k) '); Readln(Ch); Until UpCase(Ch) = 'K'; ClrScr; Writeln('CHUOI THU HAI'); Writeln(' '); Writeln; i := 0; Repeat i := i + 1; New(Tam); Write('-Ky tu thu: ',i:2,' : '); Readln(Tam^.Kt); If i = 1 Then Begin Dau2 := Tam; Cuoi2 := Tam; End Else Begin Cuoi2^.Next := Tam; Cuoi2 := Tam; End; Write('Nhap nua khong ? (c/k) '); Readln(Ch); Until UpCase(Ch) = 'K'; Cuoi1^.Next := Dau2; Cuoi2^.Next :=Nil; Writeln; Writeln(' KET QUA'); Writeln(' '); Tam := Dau1; While Tam <> Nil Do Begin Write(Tam^.Kt); Tam := Tam^.Next; End; Writeln; Write(' Bam <Enter> . . . '); Readln END. 11/Cây nhị phân (hay): Code: Program Cay_Nhi_Phan; Uses Crt; TYPE Str = String[24]; ConTro = ^BanGhi; BanGhi = RECORD HoTen : Str; Luong : Real; Trai,Phai : ConTro; End; VAR Goc : ConTro; Nv : BanGhi; Ketthuc : Boolean; Ch : Char; { } Procedure Chen(Var Goc : ConTro; Nv : BanGhi); Var P,P1 : ConTro; Begin If goc = Nil Then Begin New(Goc); With Goc^ Do Begin HoTen := NV.HoTen; Luong := NV.Luong; Trai := Nil; Phai := Nil; End; End Else Begin [...]... Do Begin For j:=1 To 6 Do Write(a[i,j]:8); Writeln; End; Readln End 25/Giải hệ phuơng trình tuyến tính 2 ẩn: Code: Program Giai_he_PT_tuyen_tinh; Var A:Array[1 2, 1 2] Of Real; C:Array[1 2] Of Real; x,y,dt,dtx,dty:Real; i,j:Integer; Begin Writeln('GIAI HE PT TUYEN TINH 2 AN'); Writeln(' '); Writeln; Writeln('-Nhap cac he so A cua he phuong trinh: '); For i:=1 to 2 Do For j:=1 To 2 Do Begin... spt Do Write(a[i]:6); Writeln; Writeln('-Tong so cac so le la: ',sole); Writeln; Writeln(' Bam phim de ket thuc '); Readln End 18/Tính giá trị của đa thức bậc N: Code: Program Da_thuc; Var a:Array[1 255] Of Real; i,n:Byte; x,p:Real; Begin Writeln('TINH GIA TRI CUA DA THUC BAC N'); Writeln(' '); Writeln; Write('-Cho biet bac cua da thuc: '); Readln(n); For i:= N Downto 0 Do Begin... tra kí tự trùng của 2 chuổi: Code: Program Cung_Ky_Tu; Var St1,St2:String; Dung:Boolean; i:Integer; Begin Writeln('KIEM TRA KY TU TRUNG CUA 2 CHUOI'); Writeln(' '); Writeln; Write('-Nhap chuoi 1: '); Readln(St1); Write('-Nhap chuoi 2: '); Readln(St2); Dung:=False; If Length(St1)=Length(St2) Then Begin Dung:=True; For i:= 1 To Length(St1) Do If Pos(St1[i],St2) = 0 Then Dung:=False Else Delete(St2,Pos(St1[i],St2),1);... -'); Writeln; Goc := Nil; KetThuc := False; Repeat With Nv Do Begin Write('-Ho ten hoac de ngung: '); Readln(HoTen); If HoTen '' Then Begin Write('-Bac luong : '); Readln(Luong); Chen(Goc,Nv); End Else KetThuc := True; End; Until ketThuc; End; '2' : Begin ClrScr; Writeln; Writeln('2-NOI VAO CAY THEO THU TU'); Writeln(' -'); Writeln; KetThuc := False; Repeat With Nv Do Begin Write('-Ho... Writeln('3.XOA KHOI CAY'); Writeln(' '); Writeln; KetThuc := False; Repeat With Nv Do Begin Write('Ho ten can xoa, hoac de ngung: '); Readln(HoTen); '4' If HoTen '' Then Xoa(Goc,NV) Else KetThuc := True; End; Until KetThuc; End; : Begin ClrScr; Writeln('4-TIM KIEM TREN CAY'); '5' : CAY'); Writeln(' -'); Writeln; ketThuc := False; Repeat With Nv Do Begin Write('Ho ten can tim, hoac ... Readln(tiep); If UpCase(tiep)='C' Then Goto l1; End 30/Kiểm tra số nhập vào: Code: Program Kiem_tra_so; Label tt; Var St:String; So:Real; Dung:Integer; tiep:Char; Begin Repeat Writeln('KIEM TRA SO NHAP VAO'); Writeln(' -'); tt:Write('-Nhap mot so: '); Readln(St); Val(St,So,Dung); If Dung = 0 Then Writeln(' +Ban da nhap mot so: ',So:8:2) Else Writeln(' +Khong phai so, xin nhap lai:'); Until Dung... Writeln('-Ky tu: ',Ch,' ma ASCII = ',a[ch]); End; Writeln; Writeln('Bam phim de ket thuc'); Readln End 14/Trung bình cộng: Code: Program Tb_cong; Var i,so,dem,tong:Integer; Tb:Real; A:Array[1 100] Of Integer; Begin Writeln('TINH TRUNG BINH CONG CAC SO NGUYEN'); Writeln(' '); Writeln; dem:=0; Tong:=0; Write('-Nhap so nguyn: '); Readln(so); While so > 0 Do Begin dem:=dem+1; a[dem]:=so;... i:=1 To spt Do Write(a[i]:6); Writeln; Writeln(' Bam phim de ket thuc '); Readln End 42/Giải thuật tìm kiếm tuyến tính: Code: Program Tim_Tuyen_Tinh; Const N=10; Var a:array[1 N] Of Integer; so,i:Integer; Begin Writeln('GIAI THUAT TIM KIEM TUYEN TINH'); Writeln(' '); Writeln; For i:=1 To N Do Begin Write('-Phan tu A[',i,']= '); Readln(a[i]); End; Writeln; Write('-So can tim: ');... Writeln('+So thap phan: ',So1); Writeln('+So La ma : ',St); Writeln; Writeln(' Readln End Bam phim de ket thuc'); 36/Mãng số thực: Code: Program Mang_so_thuc; Const Max = 100; Type Mang=Array[1 Max] Of Real; Var i,n:Integer; A:mang; Begin Writeln('MANG SO THUC'); Writeln(' '); Repeat Write('-Cho biet so phan tu: '); Readln(N); Until N . 1. al của Tin Học 11 - Phần 1  Giáo trình lập trình Pascal nâng cao -Mediafire 25 /11/ 2 011  CD-ROM Giáo trình Pascal 07/02/2013 1/Sắp Xếp Theo Tên: Code:. '); Readln End. 18/Tính giá trị của đa thức bậc N: Code: Program Da_thuc; Var a:Array[1 255] Of Real; i,n:Byte; x,p:Real; Begin Writeln('TINH GIA TRI CUA DA THUC BAC N'); . End. 6/Tính điểm xếp hạng: Code: Program Tinh_Diem_Xep_Hang; TYPE ConTro = ^Lop; Lop = RECORD HoTen : String[24]; NamSinh : Integer; Tb1,Tb2,Tb : Real; End; VAR Hs : Array[1 50] Of lop;

Ngày đăng: 01/04/2014, 03:20

TỪ KHÓA LIÊN QUAN

w