- 14 Tháng năm 2017
- 3,974
- 7,623
- 744
- 22
- Phú Yên
- Trường THPT Lương Văn Chánh
Chắc suất Đại học top - Giữ chỗ ngay!! ĐĂNG BÀI NGAY để cùng trao đổi với các thành viên siêu nhiệt tình & dễ thương trên diễn đàn.
Mã:
program danh_bai;
uses crt,dos;
var lb,lb1,hi,hi1,ng,ng1,mau,mau1,dim,dim1: array[1..20] of integer;
hinh,hinh1,bai,bai1 : array[1..20] of string;
h,h1,x,x1,n,n1,c,diem,diem1,db,dbb,cc,ch,thua,thang,xilat: integer;
thm,thm1,key,ky,xl: string;
s,z,a,aa,aaa,aaaa,l,l1,l2,l3,q,p,tai: integer;
tb,tb1: boolean;
f: text;
tien: longint;
m1,m2,m3,m4: integer;
function mousex:word;assembler;asm
mov ax,3; int 33h; mov ax,cx end;
function mousey:word;assembler;asm
mov ax,3; int 33h; mov ax,dx end;
function leftclick:boolean;assembler;asm
mov ax,3; int 33h; and bx,1; mov ax,bx end;
function rightclick:boolean;assembler;asm
mov ax,3; int 33h; and bx,2; mov ax,bx end;
function MouseArea(x1,x2,y1,y2:word):boolean;
begin
if (mousex div 8+1 >=x1)
and (mousex div 8+1 <=x2)
and (mousey div 8+1 >=y1)
and (mousey div 8+1 <=y2)
then mousearea:=true
else mousearea:=false;
end;
Function InitMouse : boolean;
var r: registers;
Begin
r.ax:=$00;intr($33,r);
if r.ax<>0 then InitMouse:=true
else InitMouse:=false;
End;
Procedure ShowMouse;
Var r: registers;
begin
r.ax:=$01;intr($33,r);
End;
procedure setcusor(bot,top: byte);
var regs : registers;
begin
regs.ah :=1;
regs.ch:=bot;
regs.cl:=top;
intr($10,regs);
end;
procedure taolabai;
begin
textcolor(12);
gotoxy(x-2,23);write(#218+#196+#196+#196+#196+#191);
gotoxy(x-2,25);write(#192+#196+#196+#196+#196+#217);
gotoxy(x-2,24);write(#179);
gotoxy(x+3,24);write(#179);
end;
procedure taoquanbai;
begin
x:=5;
for h:=1 to 10 do begin
lb[h]:=random(14);
while lb[h] < 1 do lb[h]:=random(14);
if lb[h]=1 then begin bai[h]:='A';dim[h]:=1;end;
if lb[h]=2 then begin bai[h]:='2';dim[h]:=2;end;
if lb[h]=3 then begin bai[h]:='3';dim[h]:=3;end;
if lb[h]=4 then begin bai[h]:='4';dim[h]:=4;end;
if lb[h]=5 then begin bai[h]:='5';dim[h]:=5;end;
if lb[h]=6 then begin bai[h]:='6';dim[h]:=6;end;
if lb[h]=7 then begin bai[h]:='7';dim[h]:=7;end;
if lb[h]=8 then begin bai[h]:='8';dim[h]:=8;end;
if lb[h]=9 then begin bai[h]:='9';dim[h]:=9;end;
if lb[h]=10 then begin bai[h]:='10';dim[h]:=10;end;
if lb[h]=11 then begin bai[h]:='J';dim[h]:=10;end;
if lb[h]=12 then begin bai[h]:='Q';dim[h]:=10;end;
if lb[h]=13 then begin bai[h]:='K';dim[h]:=10;end;
end;
for h:=1 to 10 do begin
hi[h]:=random(5);
while hi[h]<1 do hi[h]:=random(5);
if hi[h]=1 then begin hinh[h]:=#259;mau[h]:=4;end;
if hi[h]=2 then begin hinh[h]:=#260;mau[h]:=4;end;
if hi[h]=3 then begin hinh[h]:=#261;mau[h]:=9;end;
if hi[h]=4 then begin hinh[h]:=#262;mau[h]:=9;end;
end;
for h:=1 to n do begin
x:=x+6;
ng[h]:=random(5);
while ng[h]<1 do ng[h]:=random(4);
taolabai;
end;
end;
procedure taolabaimay;
begin
textcolor(12);
gotoxy(x1-2,1);write(#218+#196+#196+#196+#196+#191);
gotoxy(x1-2,3);write(#192+#196+#196+#196+#196+#217);
gotoxy(x1-2,2);write(#179);
gotoxy(x1+3,2);write(#179);
end;
procedure taoquanbaimay;
begin
x1:=5;
for h1:=1 to 10 do begin
lb1[h1]:=random(14);
while lb1[h1] < 1 do lb1[h1]:=random(14);
if lb1[h1]=1 then begin bai1[h1]:='A';dim1[h1]:=1;end;
if lb1[h1]=2 then begin bai1[h1]:='2';dim1[h1]:=2;end;
if lb1[h1]=3 then begin bai1[h1]:='3';dim1[h1]:=3;end;
if lb1[h1]=4 then begin bai1[h1]:='4';dim1[h1]:=4;end;
if lb1[h1]=5 then begin bai1[h1]:='5';dim1[h1]:=5;end;
if lb1[h1]=6 then begin bai1[h1]:='6';dim1[h1]:=6;end;
if lb1[h1]=7 then begin bai1[h1]:='7';dim1[h1]:=7;end;
if lb1[h1]=8 then begin bai1[h1]:='8';dim1[h1]:=8;end;
if lb1[h1]=9 then begin bai1[h1]:='9';dim1[h1]:=9;end;
if lb1[h1]=10 then begin bai1[h1]:='10';dim1[h1]:=10;end;
if lb1[h1]=11 then begin bai1[h1]:='J';dim1[h1]:=10;end;
if lb1[h1]=12 then begin bai1[h1]:='Q';dim1[h1]:=10;end;
if lb1[h1]=13 then begin bai1[h1]:='K';dim1[h1]:=10;end;
end;
for h1:=1 to 10 do begin
hi1[h1]:=random(5);
while hi1[h1]<1 do hi1[h1]:=random(5);
if hi1[h1]=1 then begin hinh1[h1]:=#259;mau1[h1]:=4;end;
if hi1[h1]=2 then begin hinh1[h1]:=#260;mau1[h1]:=4;end;
if hi1[h1]=3 then begin hinh1[h1]:=#261;mau1[h1]:=9;end;
if hi1[h1]=4 then begin hinh1[h1]:=#262;mau1[h1]:=9;end;
end;
for h1:=1 to n1 do begin
x1:=x1+6;
ng1[h1]:=random(5);
while ng1[h1]<1 do ng1[h1]:=random(4);
taolabaimay;
end;
end;
procedure inlabai;
begin
if (tb) or (h=1) then begin
gotoxy(x,24);
textcolor(15);
write(bai[h]);
textcolor(mau[ng[h]]);write(hinh[ng[h]]);
diem:=diem+dim[h];
end;
end;
procedure inlabaimay;
begin
if (not tb) then begin
gotoxy(x1,2);
textcolor(15);
write(bai1[h1]);
textcolor(mau1[ng1[h1]]);write(hinh1[ng1[h1]]);
diem1:=diem1+dim1[h1];
end;
end;
procedure thembai;
var mi1,mi2: integer;
begin
mi1:=6;
mi2:=6;
Initmouse;
Showmouse;
rightclick;
{============================================================}
gotoxy(40,15);clreol;
gotoxy(40,16);clreol;
if (thm='y') and (n<=10) then begin
repeat
Showmouse;
textcolor(mi1);
gotoxy(40,15);write('Them Bai');
textcolor(mi2);
gotoxy(40,17);write('Thoi');
if (leftclick) and
(mousearea(1,78,15,15)) then
thm:='y';
if (leftclick) and (mousearea(1,78,17,17)) then
thm:='n';
if (mousearea(1,78,15,15)) then begin mi1:=4;mi2:=6;end;
if (mousearea(1,78,17,17)) then begin mi2:=4;mi1:=6;end;
if ((not mousearea(1,78,15,15)) and (not mousearea(1,78,17,17)))
then begin mi1:=6;mi2:=6;end;
until (leftclick) and ((mousearea(1,78,15,15))
or (mousearea(1,78,17,17)));
{===============================================}
if thm='y' then begin delay(300);
n:=n+1;tb:=true;end;
if thm<>'y' then begin tb:=false;end;
end;
end;
procedure khuibai;
begin
if (not tb) and (not tb1) then begin
gotoxy(1,15);clreol;
gotoxy(1,17);clreol;textcolor(5);
gotoxy(30,10);write('Khui bai ban...');delay(1200);
gotoxy(30,10);clreol;
gotoxy(30,10);
write('Diem cua ban : ',diem);repeat until leftclick;
gotoxy(30,10);clreol;
gotoxy(30,10);write('Khui bai may...');delay(1200);
gotoxy(30,10);clreol;
gotoxy(30,10);write('Diem cua may: ',diem1);
repeat until leftclick;
clrscr;c:=0;
end;
end;
procedure thembaimay;
begin
if not tb then begin
if (diem1<diem) and (diem<=21) and (n1<10)
then begin thm1:='y';tb1:=true;
end;
if (diem1<16) and (diem>21) and (n1<10)
then begin thm1:='y';tb1:=true;
end;
if (diem1<16) and (diem<16) and (n1<10)
then begin thm1:='y';tb1:=true;
end;
if ((diem1>=diem) and (diem1>=16)) or (n1>=10) then begin thm1:='n';tb1:=false;end;
if ( (diem1>=16) and (diem>21) ) or (n1>=10) then begin thm1:='n';tb1:=false;end;
if (thm1='y') and (n1<10) then begin
n1:=n1+1;end;
end;
end;
procedure thangthua;
begin
if (not tb) and (not tb1) then begin
if (diem>diem1) and (diem1>=16) and (diem1<=21)
and (diem>=16) and (diem<=21) then thang :=1;
if (diem1>diem) and (diem1>=16) and (diem1<=21)
and (diem>=16) and (diem<=21)
then thua :=1;
if (diem1>=16) and (diem1<=21) and ( (diem<16) or (diem>21))
then thua:=1;
if (diem>=16) and (diem<=21) and ( (diem1<16) or (diem1>21))
then thang:=1;
if thang=1 then tien:=tien+cc div 2;
if (thua=1) then tien:=tien-cc div 2;
if thang=1 then tien:=tien+cc div 2;
if (thua=1) then tien:=tien-cc div 2;
end;
if (tb) or (tb1) then begin
thua:=2;thang:=2; end;
end;
procedure tienchoi;
begin
rewrite(f);
write(f,tien);
close(f);
end;
procedure motienchoi;
begin
reset(f);
read(f,tien);
close(f);
end;
procedure themtien;
begin
tien:=1000;
rewrite(f);write(f,tien);
close(f);
end;
procedure Print;
begin
textcolor(14);
gotoxy(14,8);
write('MENU');
textcolor(m1);
gotoxy(15,10);
write('Bat dau.');
textcolor(m2);
gotoxy(15,11);
write('So tien cua ban.');
textcolor(m3);
gotoxy(15,12);
write('Huong dan choi.');
textcolor(m4);
gotoxy(15,13);
write('Thoat.');
end;
procedure menu;
begin
InitMouse;
clrscr;
m1:=15;m2:=15;m3:=15;m4:=15;
while s<>0 do begin
Print;
Showmouse;
if mousearea(1,48,10,10) then begin
m1:=2;m2:=15;m3:=15;m4:=15;end;
if mousearea(1,48,11,11) then begin
m2:=2;m1:=15;m3:=15;m4:=15;end;
if mousearea(1,48,12,12) then begin
m3:=2;m2:=15;m1:=15;m4:=15;end;
if mousearea(1,48,13,13) then begin
m4:=2;m2:=15;m3:=15;m1:=15;end;
if (not mousearea(1,48,10,10)) and (not mousearea(1,48,11,11)) and
(not mousearea(1,48,12,12)) and (not mousearea(1,48,13,13))
then begin
m1:=15;m2:=15;m3:=15;m4:=15;end;
if (leftclick) and (mousearea(1,48,10,10)) then begin s:=0;clrscr;end;
if ((leftclick) and (mousearea(1,48,11,11))) then begin
clrscr;
delay(200);
motienchoi;
textcolor(15);
writeln(' Tien cua ban: ',tien);
repeat Showmouse; until leftclick;
if tien<=0 then begin write(' Ban co muon them tien khong?(y=yes) ');readln(xl);
if xl='y' then themtien;clrscr;end;
clrscr;
end;
if (leftclick) and(mousearea(1,48,12,12)) then begin
delay(200);
clrscr;gotoxy(2,2); textcolor(3);
writeln(' Huong dan choi:');
writeln;
write(' Ban co quyen them bai (toi da 10 la) de cho so diem cua ban');
write(' cao hon may (diem phai lon hon 15 va nho hon 22). ');
write(' Diem cua ban la diem cua cac la bai');
write(' (cac la J, Q,K la 10 diem). Ban phai dat cuoc truoc khi choi( tien chan)');
write(' de nhan tien khi thang va se bi tru tien khi thua.');
write(' Tien se duoc luu lai sau khi choi.');
repeat Showmouse; until leftclick;
clrscr;
end;
if (leftclick) and (mousearea(1,48,13,13)) then
begin ch:=0;c:=0;clrscr;break;exit;end;
setcusor(32,3);
z:=2;
if l<> 13 then begin c:=1;end;
end;
clrscr;
end;
procedure taimay;
begin
Showmouse;
gotoxy(25,11);textcolor(5);
writeln(#218+#196+#196+#196+#196+#196+#196+#196+#196
+#196+#196+#196+#196+#196+#196+#196+#196+#196+#196+#196+#196+#196
+#196+#196+#191);
gotoxy(49,12);
write(#179);
gotoxy(25,12);
write(#179);
gotoxy(25,13);
writeln(#192+#196+#196+#196+#196+#196+#196+#196+#196
+#196+#196+#196+#196+#196+#196+#196+#196+#196+#196+#196+#196+#196
+#196+#196+#217);textcolor(14);
gotoxy(33,10);write('Dang tai');
textcolor(14+blink);write('...');
for tai:=27 to 47 do begin
gotoxy(tai,12);textcolor(4);
write(#219);
gotoxy(34,14); textcolor(2);
write('...',(tai-27)*5,'%...');
if tai=35 then delay(1500);
delay(150); end;
clrscr;
end;
BEGIN
textbackground(black);
ch:=5;
assign(f,'tien.txt');
tienchoi;
motienchoi;
s:=1;
a:=2;
aa:=15;aaa:=15;aaaa:=15;
l:=10;l1:=11;l2:=12;l3:=13;
menu;
if ch<> 0 then taimay;
while ch<>0 do begin
clrscr;
diem:=0;
diem1:=0;
n:=1;
n1:=1;
c:=100;
thm1:='y';
thm:='y';
randomize;
setcusor(32,3);
textcolor(5);
if ch<>0 then begin
write('Ban muon cuoc bao nhieu: ');readln(cc);end;
while ((cc>tien) or (cc<0) or (cc mod 2 <> 0)) and (ch<>0) do begin
clrscr;write('Ban muon cuoc bao nhieu: ');readln(cc);
end;
clrscr;
while c<>0 do begin
begin
textcolor(12);
gotoxy(1,20);write(#218+#196+#196+#196+#196+#196+#196+#196+#196
+#196+#196+#196+#196+#196+#196+#196+#196+#196+#196+#196+#191);
gotoxy(1,22);write(#192+#196+#196+#196+#196+#196+#196+#196+#196
+#196+#196+#196+#196+#196+#196+#196+#196+#196+#196+#196+#217);
gotoxy(1,21);write(#179);gotoxy(21,21);write(#179);
textcolor(6);
gotoxy(2,21);write('Tien cuoc: ',cc);
textcolor(12);
gotoxy(55,20);write(#218+#196+#196+#196+#196+#196+#196+#196+#196
+#196+#196+#196+#196+#196+#196+#196+#196+#196+#196+#196+#191);
gotoxy(55,22);write(#192+#196+#196+#196+#196+#196+#196+#196+#196
+#196+#196+#196+#196+#196+#196+#196+#196+#196+#196+#196+#217);
gotoxy(55,21);write(#179);gotoxy(75,21);write(#179);
gotoxy(56,21);
textcolor(14);
write('Tien Cua Ban: ',tien);
end;
taoquanbai;
taoquanbaimay;
inlabaimay;
inlabai;
thembai;
thembaimay;
khuibai;
thangthua;
end;
if ch<>0 then begin
Showmouse;
if (thang=1) then begin
delay(200);
textcolor(2);
gotoxy(30,13);write('Ban thang roi.');
repeat Showmouse; until leftclick;
clrscr;end;
if (thua=1) then begin
delay(200);
textcolor(2);
gotoxy(30,13);write('Ban thua roi.');
repeat Showmouse; until leftclick;
clrscr;end;
if (thua<>1) and (thang<>1) then begin
delay(200);
textcolor(2);
gotoxy(30,13);write('Hai nguoi hoa.');
repeat Showmouse; until leftclick;
clrscr;end;
m1:=14;m2:=14;
if tien>=0 then begin textcolor(14);
delay(500);
repeat
Showmouse;
textcolor(m1);
gotoxy(1,1);write(' Choi tiep. ');
textcolor(m2);
gotoxy(1,3);write(' Ngung choi. ');
if (mousearea(1,78,1,1)) then begin m1:=6;m2:=14;end;
if (mousearea(1,78,3,3)) then begin m2:=6;m1:=14;end;
if (not mousearea(1,78,1,1)) and (not mousearea(1,78,3,3))
then begin m1:=14;m2:=14;end;
until (leftclick) and ((mousearea(1,78,1,1)) or (mousearea(1,78,3,3)));
if (leftclick) and (mousearea(1,78,1,1)) then key:='y';
if (leftclick) and (mousearea(1,78,3,3)) then key:='n';
end;
if key='n' then begin c:=0;ch:=0;end;
if tien<0 then begin ch:=0;textcolor(6);
write('Ban het tien roi...');delay(1000);end;
end; end;
tienchoi;
END.