BÀI TẬP LẬP TRÌNH - DEMO CÁC PHƯƠNG PHÁP SẮP XẾP

37 754 1
BÀI TẬP LẬP TRÌNH - DEMO CÁC PHƯƠNG PHÁP SẮP XẾP

Đ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

Program BAI_TAP_CHU_DE_LON1; Uses Dos,Crt,graph; Type mang = array [1..10] of string; m1 = array [1..21] of byte; Const dong = 10; old = 15; tg = 60000; MAU=159; mau2=120; Var k:array[1..10] of string; dc:char; Gd,Gm : Integer; Radius,T : Integer; a : m1; f1,f2:m1; n,l,i,h1,h2,p,pm : byte; ss,hv : word; Procedure ConTro(co:byte); Var R : Registers; Begin R.AH:=$01; If co = 0 Then R.CX:=$2000 Else R.CX:=$0B0C; Intr($10,R); End;

Program BAI_TAP_CHU_DE_LON1; Uses Dos,Crt,graph; Type mang = array [1 10] of string; m1 = array [1 21] of byte; Const dong = 10; old = 15; tg = 60000; MAU=159; mau2=120; Var k:array[1 10] of string; dc:char; Gd,Gm : Integer; Radius,T : Integer; a : m1; f1,f2:m1; n,l,i,h1,h2,p,pm : byte; ss,hv : word; Procedure ConTro(co:byte); Var R : Registers; Begin R.AH:=$01; If co = Then R.CX:=$2000 Else R.CX:=$0B0C; Intr($10,R); End; Procedure writeXYso(x,y,tt,i:byte); Begin textattr:=tt; gotoxy(x,y-1);write('ÚÄÄ¿'); gotoxy(x,y);write('³',a[i]:2,'³'); gotoxy(x,y+1);write('ÀÄÄÙ'); textattr:=old; End; { -Nhap du lieu } Procedure nhapdulieu (var dulieu:m1); Var i: integer; Begin clrscr; write('Day so can sap xep co bao nhieu so: ');readln(n); randomize; For i:=1 to n dulieu[i]:=random(100); end; Procedure xuat(f:m1); Var i:byte; Begin clrscr; for i:=1 to n begin writexyso(i*4-3,dong,old,i); end; End; Procedure xuat1(f:m1;n:byte); Var i:byte; Begin clrscr; for i:=1 to n begin writexyso(i*4-3,dong,mau,i);end; End; procedure banphim; var i:integer; begin clrscr; ConTro(1); write('Nhap vao so phan tu : ');readln(n); for i:=1 to n begin gotoxy(5,18);write('Nhap vao phan tu thu ',i,' : ');readln(a[i]); xuat1(a,i); gotoxy(5,18);write(' '); end; ConTro(0); end; Procedure writeXYchuoi(x,y:byte;chuoi:string;tt:byte); Begin gotoxy(x,y); textattr:=tt; write(chuoi); textattr:=old; End; Function TaoMenu(x,y,max:byte;tieude:mang):byte; Var chon : byte; kt : char; Begin For chon:=1 to max writexychuoi(x,y+chon,tieude[chon],old); chon:=1; Repeat writexychuoi(x,y+chon,tieude[chon],31); kt:=readkey; if kt=#0 then kt:=readkey; writexychuoi(x,y+chon,tieude[chon],old); case kt of #80:if chon1 then dec(chon) else chon:=max; end; Until kt=#13; Taomenu:=chon; End; { Nhap -} Procedure NHAP; Var ch,i : byte; tieude : mang; Begin clrscr; tieude[1]:='1 Nhap bang co che sinh so ngau nhien'; tieude[2]:='2 Nhap tu Ban phim '; ch:=taomenu(30,8,2,tieude); clrscr; case ch of 1:nhapdulieu(a); 2:BanPhim; end; clrscr; Writexychuoi(28,1,'DAY SO BAN DAU',15); For i:=1 to n writexyso(i*4-3,3,old,i); End; { -} Procedure clr; Var i,j:byte; Begin For i:=6 to 16 {6} for j:=1 to 100 write(#32); End; Procedure Xoa(x,y:byte); Begin gotoxy(x,y-1);write(' '); {1} gotoxy(x,y);write(' '); gotoxy(x,y+1);write(' '); End; { HVi -} Procedure HVi(var i,j:byte); Var x,coti,dongi,cotj,dongj : byte; Begin coti:=i*4-3; cotj:=j*4-3; writexyso(coti,dong,159,i); writexyso(coti,dong,159,j); delay(tg); xoa(coti,dong); xoa(cotj,dong); dongi:=dong-3; dongj:=dong+3; WriteXYso(coti,dongi,159,i); WriteXYso(cotj,dongj,159,j); delay(tg); While (cotij*4-3)or(cotji*4-3) begin xoa(coti,dongi);xoa(cotj,dongj); if i

Ngày đăng: 19/08/2013, 09:35

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan