Bài toán loại 2 D :
program duonghaichieu;
uses crt,graph;
type
point_2d = record
x,y:real;
end;
var
m,n:integer;
cgx,cgy,x,b,xgoc,ygoc:real;
p1,p2:point_2d;
xmin:real;
ymin: real;
xmax:real;
ymax:real;
maxx:integer;
maxy:integer;
{Chuyen tu cua so thuc sang cs nhin}
procedure wtv(p:point_2d;var q:point_2d);{chuyen sang cs nhin}
begin
q.x:=p.x*cgx;
q.y:=p.y*cgy;
end;
{Chuyen tu cs nhin sang man hinh}
procedure vts(p:point_2d; var q:point_2d);{chuyen sang man hinh}
begin
q.x:=xgoc+p.x;
q.y:=ygoc-p.y;
end;
{Ve he truc toa do}
procedure hetruc;
ymin:=cgy*ymin;
ymax:=cgy*ymax;
{Tinh toa do he truc}
xgoc:=0;
if xgoc>xmin then xgoc:=round(abs(xmin));
ygoc:=0;
if ygoc<ymax then ygoc:=round(abs(ymax));
hetruc;
{Chuyen diem dau tien vao cua so man hinh de ve}
x:=xmin;
p1.x:=x;
p1.y:=bp(x);
wtv(p1,p2);
p1:=p2;
vts(p2,p2);
moveto(round(p2.x),round(p2.y));
repeat
p1.x:=x;p1.y:=bp(x);
wtv(p1,p2);
p1:=p2;
vts(p2,p2);
lineto(round(p2.x),round(p2.y));
x:=x+b;
until x>2*pi-xmin+b;
readln;
closegraph;
end.
uses crt,graph;
type
mt1= array[1 1,1 3] of real;
begin
for i:=1 to 3 do
for j:=1 to 3 do
c[i,j]:=0;
for i:=1 to 3 do
for k:=1 to 3 do
for j:=1 to 3 do
c[i,k]:=c[i,k]+a[i,j]*b[j,k];
end;
begin
clrscr;
write('Nhap toa do diem A: ');
readln(a.x,a.y);
write('Nhap toa do diem B: ');
readln(b.x,b.y);
write('Nhap toa do diem C: ');
readln(c.x,c.y);
{ write('Nhap Tx =');readln(tx);
write('Nhap Ty =');readln(ty);
mta[1,1]:=a.x;mta[1,2]:=a.y;mta[1,3]:=1;
mtb[1,1]:=b.x;mtb[1,2]:=b.y;mtb[1,3]:=1;
mtc[1,1]:=c.x;mtc[1,2]:=c.y;mtc[1,3]:=1;
mttt[1,1]:=1;mttt[2,1]:=0;mttt[3,1]:=tx;
mttt[1,2]:=0;mttt[2,2]:=1;mttt[3,2]:=ty;
mttt[1,3]:=0;mttt[2,3]:=0;mttt[3,3]:=1;
mt1333(mta,mttt,mtkqa);
mt1333(mtb,mttt,mtkqb);
mt1333(mtc,mttt,mtkqc);
kqa.x :=mtkqa[1,1];kqa.y:=mtkqa[1,2];
kqb.x :=mtkqb[1,1];kqb.y:=mtkqb[1,2];
setcolor(red);
line(round(a.x),round(a.y),round(b.x),round(b.y));
line(round(a.x),round(a.y),round(c.x),round(c.y));
line(round(c.x),round(c.y),round(b.x),round(b.y));
setcolor(white);
line(round(kqa.x),round(kqa.y),round(kqb.x),round(kqb.y));
line(round(kqb.x),round(kqb.y),round(kqc.x),round(kqc.y));
line(round(kqc.x),round(kqc.y),round(kqa.x),round(kqa.y));
readln;
closegraph;
end.
Bài toán loại 3D :
Program DOTHI;
Uses crt,graph,gmenu,minh3,mouses;
Type
Data=record
Dta:real;
at:byte;
end;
VAR
ghA,ghB,No:real;
Malenh,Maham,Ndoan:integer;
Y:array[1 3]of real;
BT:array[1 128]of data;
BT_ham,tip:string;
Fit:boolean;
Xtus,Ytus:integer;
Ntt,nn:byte;
i,j:integer;
(***********************************************************************
Zone(Xmin,Ymin,Xmax,Ymax,1,Hicolor);
GetOwnInfo;M_off;
if ghA=ghB then if ghA=0 then ghB:=1 else ghA:=-ghB;
if ghA>ghB then begin ghA:=ghA+ghB; ghB:=ghA-ghB; ghA:=ghA-ghB;end;
i:=0;while (not f(ghA+(ghB-ghA)*(i/Ndoan)))and(i<=Ndoan)do
i:=i+1;Fmin:=y[1];fmax:=fmin;
for i:=0 to Ndoan do
if f(ghA+(ghB-ghA)*(i/Ndoan))then
for j:=1 to NN do begin if fmin>y[j] then fmin:=y[j];
if fmax<y[j] then fmax:=y[j];end;
if Fmax<>Fmin then
Begin
tX:=(Xmax-Xmin)/(ghB-ghA);
tY:=(Ymax-Ymin)/abs(fmax-fmin);
if not fit then if (tX>tY)then tX:=tY else tY:=tX;
setcolor(7);
dX:=round(((Xmax-Xmin)-(ghB-ghA)*tX)/2);
dY:=round(((Ymax-Ymin)-(fmax-fmin)*tY)/2);
if (ghA*ghB)<=0 then
begin
line(Xmin+dx-round(ghA*tX),Ymax,Xmin+dx-round(ghA*tX),Ymin);
moveto(Xmin+dx-round(ghA*tX),ymin);linerel(1,8);linerel(-2,0);linerel(1,-8);
outtextxy(Xmin+dx-round(ghA*tX)+3,ymin+2,'Y');
end;
if (fmin*fmax)<=0 then
begin
line(Xmin,Ymax-dy+round(fmin*tY),Xmax,Ymax-dy+round(fmin*tY));
moveto(Xmax,Ymax-dy+round(fmin*tY));linerel(-8,1);linerel(0,-2);linerel(8,1);
outtextxy(Xmax-8,Ymax-dy+round(fmin*tY)-10,'X');
outtextxy(Xmin+dx-round(ghA*tX)+3,Ymax-dy+round(fmin*tY)-8,'0');
else Buttontext(Xtus+570,Ytus,50,21,'None');
End;
{ }
Procedure manhinh;
var i:integer;
Begin menuflag:=true;
Window(0,1,GetmaxX,GetmaxY,0,'Do thi ham so y=F(x) trong khoang [a,b]');
AddButton(GetmaxX-H_buttool-2,1,H_Buttool ,32,'X',100);
if menuflag then begin Initmenu(Xmin,YMin);Ymin:=Ymin+H_Button+1;end;
Zone(Xmin,Ymin,Xmax,YMin+H_button+2,2,Bcolor);Ymin:=Ymin+1;
GetOwninfo;M_off;
Settextjustify(lefttext,1);settextstyle(Ttype,Tdir,Tsize);setcolor(Tcolor);
outtextxy(Xmin+3,Ymin+H_button div 2-1,' Ham so:');
outtextxy(Xmin+305,Ymin+H_button div 2-1,' Gioi han:');
outtextxy(Xmin+470,Ymin+H_button div 2-1,' N§:X Y');
SetOwninfo;M_on;Xtus:=xmin;Ytus:=Ymin;
Ymin:=Ymin+H_Button+3;
AddButton(Xmin,Ymin,48,0,'Axý+Bx+C',1);
AddButton(Xmin,Ymin+H_Button+1,48,0,'Sin(x)',2);
AddButton(Xmin,Ymin+2*(H_Button+1),48,0,'Cos(x)',3);
AddButton(Xmin,Ymin+3*(H_Button+1),48,0,'Tan(x)',4);
AddButton(Xmin,Ymin+4*(H_Button+1),48,0,'Ln(x)',5);
AddButton(Xmin,Ymin+5*(H_Button+1),48,0,'Exp(x)',6);
AddButton(Xmin,Ymin+6*(H_Button+1),48,0,'Sqrt(x)',7);
AddButton(Xmin,Ymin+7*(H_Button+1),48,0,'Si+x/2',8);
AddButton(Xmin,Ymin+8*(H_Button+1),48,0,'Si*co(si)',9);
AddButton(Xmin,Ymin+9*(H_Button+1),48,0,'xý+yý=Rý',10);
AddButton(Xmin,Ymax-H_button,48,0,'AutoFit',12);
AddButton(Xtus+50,Ytus,250,29,'Bieu thuc tien to',20);
AddButton(Xtus+365,Ytus,50,29,'ghA',21);
'X','x':begin Ntt:=ntt+1;BT[ntt].at:=2;end;
'S','s':begin Ntt:=ntt+1;BT[ntt].dta:=11;BT[ntt].at:=1;end;
'C','c':begin Ntt:=ntt+1;BT[ntt].dta:=12;BT[ntt].at:=1;end;
end;i:=i+1;
Until i>length(BT_ham);
End;
{ }
Function Tiento(x:real):boolean;
var a,b:real;G:array[1 128]of data;i,j,l,n:byte;
Begin i:=ntt;n:=ntt;tiento:=false;
for i:=1 to ntt do begin G[i]:=BT[i];if BT[i].at=2 then G[i].dta:=x;end;
While i>0 do
Begin if (G[i].at=1) then
Case round(g[i].dta) of
1,2,3,4:if i<=n-2 then
begin tiento:=true;
case round(g[i].dta) of
1:G[i].dta:=G[i+1].dta+G[i+2].dta;
2:G[i].dta:=G[i+1].dta-g[i+2].dta;
3:G[i].dta:=G[i+1].dta*g[i+2].dta;
4:if g[i+2].dta<>0 then G[i].dta:=G[i+1].dta/g[i+2].dta
else begin tiento:=false;i:=1;end;
end; G[i].at:=0;j:=i;y[1]:=G[j].dta;nn:=1;
while (j+2)<n do begin G[j+1].dta:=G[j+3].dta;j:=j+1;end;n:=n-2;
end else begin tiento:=false;i:=1;end;
11,12:if i<=n-1 then
begin tiento:=true;
case round(G[i].dta)of
11:G[i].dta:=sin(G[i+1].dta);
12:G[i].dta:=Cos(G[i+1].dta);end;
Procedure Cuong(x0,y0,xh,yh,color:integer);
var dx,dy,tx,ty,i:integer;kc,x,y:real;
Begin datcontro(x0,y0);datmau(color);
dx:=xh-x0;dy:=yh-y0;
kc:=sqrt(abs(dx*dx+dy*dy))+1;
for i:=1 to round(kc) do
begin
x:=i; y:=kc*sin(i*2*pi/kc)/16;
tx:=round((x*dx-y*dy)/kc);
ty:=round((x*dy+y*dx)/kc);
doanden(x0+round(tx),y0+round(ty));
end;
End;
{ }
Procedure Hoa(x0,y0,R,color:integer);
var x,y,i,t:integer;di,dr:real;
Begin cuong(320,10,x0,y0,random(7));
datcontro(x0,y0);
datmau(color);t:=random(9);
for i:=1 to 180 do
begin di:=t+i*pi/90;
dr:=R*sin(4*di)*cos(t*di);
x:=x0+round(dr*cos(di));
y:=Y0+round(dr*sin(di));
doanden(x,y);
end;
End;
{ }
BEGIN randomize;
khoitao256;
VAR
Twv:MT2d;
Per,Par:MT3d;
Procedure Khoitaodohoa(BGIpath:string);
Procedure Diem(P:point2d;color:byte);
Procedure Doan(p1,p2:point2d);
Procedure Cuaso2d(x1,y1,x2,y2:real);
Procedure Tamnhin2d(x1,y1,x2,y2:Integer);
Procedure Biendoi2d(var P:point2d;M:mt2d);
Procedure Quay2d(goc:real;var MT:MT2d);
Procedure NhanMT2d(a,b:MT2d;var MT:MT2d);
Procedure KTMT2d(var mt:MT2d);
Procedure KTMT3d(var mt:MT3d);
Procedure Biendoi3d(var P:point3d;M:mt3d);
Procedure NhanMT3d(a,b:MT3d;var MT:MT3d);
Procedure Tinhtien3d(x,y,z:real;var MT:MT3d);
Procedure Quay3d(truc:char;goc:real;var MT:MT3d);
Procedure KhoitaoSongsong(g1,g2:real);
Procedure KhoitaoPhoicanh(x0,y0,z0,g1,g2,d:real);
Procedure ChieuPC(P:point3d;var Pa:Point2d);
Procedure ChieuSS(P:point3d;var Pa:Point2d);
Function Cohen3D(var p1,p2:point3D):Boolean;
Function PerClipLine(p1,p2:Point3d;var q1,q2:Point2d):boolean;
Procedure ClipPoly(np:integer;P:array of point3d;var nd:integer;var DG:array of
pointtype);
Implementation
var
XWmin,YWmin,XWmax,YWmax:real; {Window trong he toa do thuc 2D}
XVmin,YVmin,XVmax,YVmax:Integer;{Viewport trong thiet bi hien thi}
Zfront,Zback,ClipX,clipY:real; {khung nhin lap the cho phoi canh}
var t:real;
Begin
Twv[1,1]:=(XVmax-XVmin)/(XWmax-XWmin);Twv[2,1]:=0; Twv[3,1]:=0;
Twv[1,2]:=0;Twv[2,2]:=-(YVmax-YVmin)/(YWmax-YWmin); Twv[3,2]:=0;
Twv[1,3]:=XVmin-XWmin*Twv[1,1];Twv[2,3]:=YVmax-
YWmin*Twv[2,2];Twv[3,3]:=1;
End;
{ }
Procedure Cuaso2d(x1,y1,x2,y2:real);
Begin
if x1<x2 then begin XWmin:=x1;XWmax:=x2;end
else begin XWmin:=x2;XWmax:=x1;end;
if y1<y2 then begin YWmin:=y1;YWmax:=y2;end
else begin YWmin:=y2;YWmax:=y1;end;
TinhTWV;
End;
{ }
Procedure Tamnhin2d(x1,y1,x2,y2:Integer);
Begin
if x1<x2 then begin XVmin:=x1;XVmax:=x2;end
else begin XVmin:=x2;XVmax:=x1;end;
if y1<y2 then begin YVmin:=y1;YVmax:=y2;end
else begin YVmin:=y2;YVmax:=y1;end;
TinhTWV; rectangle(x1-1,y1-1,x2+1,y2+1);
End;
{ }
Procedure Biendoi2d(var P:point2d;M:mt2d);
var xt,yt,t:real;
Begin
xt:=P.x*m[1,1]+P.y*m[1,2]+m[1,3];
Procedure KTMT3D(var mt:MT3d);
var i,j:integer;
Begin
for i:=1 to 4 do for j:=1 to 4 do
if i<>j then mt[i,j]:=0 else mt[i,j]:=1;
End;
{ }
Procedure Biendoi3d(var P:point3d;M:mt3d);
var xt,yt,zt,t:real;
Begin
xt:=P.x*m[1,1]+P.y*m[1,2]+P.z*m[1,3]+m[1,4];
yt:=P.x*m[2,1]+P.y*m[2,2]+P.z*m[2,3]+m[2,4];
zt:=P.x*m[3,1]+P.y*m[3,2]+P.z*m[3,3]+m[3,4];
t:=P.x*m[4,1]+P.y*m[4,2]+P.z*m[4,3]+m[4,4];
P.x:=xt/t;P.y:=yt/t;P.z:=zt/t;
End;
{ }
Procedure Tinhtien3d(x,y,z:real;var MT:MT3d);
Begin
KtMT3D(mt);
mt[1,4]:=x;mt[2,4]:=y;mt[3,4]:=z;
End;
{ }
Procedure Quay3d(truc:char;goc:real;var MT:MT3d);
var af:real;
Begin
KTMT3d(mt);
af:=goc*pi/180;
if truc='z'then
begin mt[1,1]:=cos(af);mt[2,1]:=sin(af);
var a,b,mt:MT3d;
Begin
KTMT3d(a);a[1,4]:=-x0;a[2,4]:=-y0;a[3,4]:=-z0;
{Quay3d('z',-90-g1,b);}Quay3d('z',90-g1,b); NhanMT3d(a,b,mt);
{Quay3d('x',-90+g2,a);}Quay3d('x',-90-g2,a);NhanMT3d(mt,a,mt);
KTMT3d(a);{a[3,3]:=-1;}a[1,1]:=-1;NhanMT3d(mt,a,mt);PerClip:=mt;
KTMT3d(a);a[4,3]:=1/d;a[4,4]:=0;NhanMT3d(mt,a,mt);
Per:=mt;
Tamchieu.x:=x0;Tamchieu.y:=y0;Tamchieu.z:=z0;
MPchieu.x:=g1*pi/180;MPchieu.y:=g2*pi/180;MPchieu.z:=d;
Zfront:=1;{Zback:=;}
ClipX:=1; ClipY:=1;
Cuaso2d(-d*clipX,-d*ClipY,d*ClipX,d*clipY);
End;
{ }
Procedure ChieuPC(P:point3d;var Pa:Point2d);
Begin
Biendoi3d(P,Per);
Pa.x:=P.x;Pa.y:=P.y;
End;
{ }
Procedure ChieuSS(P:point3d;var Pa:Point2d);
Begin
Biendoi3d(P,Par);
Pa.x:=P.x;Pa.y:=P.y;
End;
{ }
Function giao(p1,p2:point3d;A,B,C,D:real;var P0:point3d):boolean;
var mau:real;
Begin
if (ma1 and ma2)<>0 then begin kq:=true;cohen3d:=false;exit;end;
if ma1=0 then
begin mtg:=ma1;ma1:=ma2;ma2:=mtg;
p0:=p1;p1:=p2;p2:=p0;dao:=not dao;
dx:=-dx;dy:=-dy;dz:=-dz;end;
if (ma1 div 32)<>0 then
giao(p2,p1,1,0,clipX,0,p0){x=-z.ClipX}
else
if ((ma1 mod 32)div 16)<>0 then
giao(p2,p1,1,0,-clipX,0,p0){x=+z.ClipX}
else
if (((ma1 mod 32)mod 16)div 8)<>0 then
giao(p2,p1,0,1,clipY,0,P0) {y=-z.ClipY}
else
if ((((ma1 mod 32)mod 16)mod 8)div 4)<>0 then
giao(p2,p1,0,1,-clipY,0,P0) {y=z.ClipY}
else
{ if (((((ma1 mod 32)mod 16)mod 8)mod 4)div 2)<>0 then
{z=Zback}
if (ma1 mod 2)<>0 then giao(p2,p1,0,0,1,-zfront,P0); {z=Zfront}
P1:=P0;
End;
End;
{ }
Function PerClipLine(p1,p2:Point3d;var q1,q2:Point2d):boolean;
var a:mt3d;
Begin PerClipLine:=false;
Biendoi3d(P1,PerClip);Biendoi3d(P2,PerClip);
if cohen3D(p1,p2)then
begin KTMT3d(a);a[4,3]:=1/MPchieu.z;a[4,4]:=0;
end;
np:=nq;for i:=1 to np do p[i]:=q[i];nq:=0;P[np+1]:=p[1];
for i:=1 to np do
begin {y:=-z*clipY}
if P[i].y>=-P[i].z*ClipY then begin nq:=nq+1;Q[nq]:=P[i];if i=1 then write(3);end;
if ((P[i].y<-P[i].z*ClipY)and(P[i+1].y>-P[i+1].z*ClipY))
or((P[i].y>-P[i].z*ClipY)and(P[i+1].y<-P[i+1].z*ClipY))
then begin giao(p[i+1],p[i],0,1,clipY,0,G);nq:=nq+1;Q[nq]:=G;end;
end;
np:=nq;for i:=1 to np do p[i]:=q[i];nq:=0;P[np+1]:=p[1];
for i:=1 to np do
begin {x:=z*clipX}
if P[i].x<=P[i].z*ClipX then begin nq:=nq+1;Q[nq]:=P[i];if i=1 then write(4);end;
if ((P[i].x<P[i].z*ClipX)and(P[i+1].x>P[i+1].z*ClipX))
or((P[i].x>P[i].z*ClipX)and(P[i+1].x<P[i+1].z*ClipX))
then begin giao(p[i+1],p[i],1,0,-clipX,0,G);nq:=nq+1;Q[nq]:=G;end;
end;
np:=nq;for i:=1 to np do p[i]:=q[i];nq:=0;P[np+1]:=p[1];
for i:=1 to np do
begin {x:=-z*clipX}
if P[i].x>=-P[i].z*ClipX then begin nq:=nq+1;Q[nq]:=P[i];if i=1 then write(5);end;
if ((P[i].x<-P[i].z*ClipX)and(P[i+1].x>-P[i+1].z*ClipX))
or((P[i].x>-P[i].z*ClipX)and(P[i+1].x<-P[i+1].z*ClipX))
then begin giao(p[i+1],p[i],1,0,clipX,0,G);nq:=nq+1;Q[nq]:=G;end;
end;
np:=nq;for i:=1 to np do p[i]:=q[i];nq:=0;
KTMT3d(mt);mt[4,3]:=1/MPchieu.z;mt[4,4]:=0;
for i:=1 to np do
begin biendoi3d(p[i],mt);
e.x:=P[i].x;e.y:=p[i].y;
maxy:integer ;
procedure c3_2(p:point_3d;var q:point_2d);
begin
q.x:=p.x +p.z*cos(g);
q.y:=p.y+p.z*sin(g);
end;
procedure wtv(p:point_2d;var q:point_2d);
begin
q.x:=p.x*cgx;
q.y:=p.y*cgy;
end;
procedure vts(p:point_2d; var q:point_2d);
begin
q.x:=xgoc+p.x;
q.y:=ygoc-p.y;
end;
procedure hetruc;
begin
setlinestyle(1,0,1);
line(round(xgoc),0,round(xgoc),getmaxy);
line(0,round(ygoc),getmaxx,round(ygoc));
line(0,round(ygoc+xgoc),639,round(ygoc+xgoc)-639);
setlinestyle(0,0,1);
end;
procedure bp(t:real;var p:point_3d);
begin
p.x:=sin(t);p.y:=cos(t);p.z:=sin(t)*cos(t);
end;
begin
clrscr;
hetruc;
t:=0;
bp(t,p3);
c3_2(p3,p1);;
wtv(p1,p2);
p1:=p2;
vts(p2,p2);
moveto(round(p2.x),round(p2.y));
repeat
bp(t,p3);
c3_2(p3,p1);
wtv(p1,p2);
p1:=p2;
vts(p2,p2);
lineto(round(p2.x),round(p2.y));
t:=t+b;
until t>2*pi+b;
readln;
closegraph;
end.
uses graph,dhmt,crt;
type
Pie=record
p:array[1 4]of Point2d;
x,y,g:integer;
end;
Var
DG:array[1 200]of Pie;
nd,cur,nx,ny,kc:integer;
x0,y0:integer;
for i:=1 to nd do
begin
for j:=1 to 4 do begin q[j].x:=round(dg[i].P[j].x);q[j].y:=round(dg[i].P[j].y);end;
q[5]:=q[1];fillpoly(4,q);drawpoly(5,q);
end;
if tt<>0 then
begin setcolor(14);setfillstyle(1,11);
for j:=1 to 4 do begin q[j].x:=round(dg[tt].P[j].x);q[j].y:=round(dg[tt].P[j].y);end;
q[5]:=q[1];fillpoly(4,q);drawpoly(5,q);
end;
setcolor(15);rectangle(x0,y0,x0+nx*kc,y0-ny*kc);
End;
{ }
Procedure Tinhtien(tt,huong:integer);
var mt:mt2d;
delta,i:byte;
Begin
ktmt2d(mt);delta:=20;
case (huong mod 5) of
1:begin mt[1,3]:=delta; dg[tt].x:=dg[tt].x+delta;end;
2:begin mt[1,3]:=-delta;dg[tt].x:=dg[tt].x-delta;end;
3:begin mt[2,3]:=delta; dg[tt].y:=dg[tt].y+delta;end;
4:begin mt[2,3]:=-delta;dg[tt].y:=dg[tt].y-delta;end;
end;
for i:=1 to 4 do biendoi2d(dg[tt].P[i],mt);
End;
{ }
Procedure Quay(tt,goc:integer);
var mt:mt2d;
c,s:real;
Function ketqua:boolean;
var i:integer;h,v:integer;
Begin
ketqua:=true;
for i:=1 to nd do
if (dg[i].x<>0)or(dg[i].y<>0)or(dg[i].g<>0)then
begin ketqua:=false;exit;end;
h:=nx*kc;v:=ny*kc;setcolor(3);
for i:=1 to v div 2 do
begin rectangle(x0+i,y0-i,x0+h-i,y0-v+i);delay(10);end;
setcolor(12);settextstyle(4,0,4);settextjustify(1,0);
outtextxy(x0+(h div 2),y0-(v div 2),'Hanh phuc');
setcolor(15+blink);settextstyle(0,0,1);settextjustify(1,0);
outtextxy(x0+(h div 2),y0,'Tiep tuc cai nhau(c/k)?:');
End;
{ }
BEGIN randomize;directvideo:=false;
Khoitaodohoa('c:\tp\bgi');
khoitao;Tanvo;cur:=1;ve(cur);
Repeat
ch:=readkey;ve(0);
case ch of
#72:tinhtien(cur,4);
#80:tinhtien(cur,3);
#75:tinhtien(cur,2);
#77:tinhtien(cur,1);
#71:if cur>1 then cur:=cur-1 else cur:=nd;
#79:if cur<nd then cur:=cur+1 else cur:=1;
#83:begin Quay(cur,1);gotoxy(10,1);write(dg[cur].g:4);end;
#81:begin Quay(cur,2);gotoxy(10,1);write(dg[cur].g:4);end;
scut1,scut2:byte;
Ma:integer;
down,right:Mipoint;
End;
MEpoint=^Menu;
Menu=Record
Name:string;
Phantu:byte;
Shortcut:byte;
Down:Mipoint;