a2vdo forum! LUQUY...tham gia nao de cung pha phach, hoc hoi...
Bạn có muốn phản ứng với tin nhắn này? Vui lòng đăng ký diễn đàn trong một vài cú nhấp chuột hoặc đăng nhập để tiếp tục.
a2vdo forum! LUQUY...tham gia nao de cung pha phach, hoc hoi...

Pha tan tanh ra, hoc hoi nhieu vao va thi do, co viec lam.kha kha!

Đăng Nhập

Quên mật khẩu



Latest topics
» Hướng dẫn kích sữa cho mẹ bầu an toàn mà hiệu quả
Bài toán tháp Hà Nội EmptyWed Sep 18, 2019 10:37 pm by chipcoiga

» Yêu là khỗ????
Bài toán tháp Hà Nội EmptyWed Oct 30, 2013 6:05 pm by ducanhle1993

» Hưỡng dẫn trang trí bài viết lên diển đàn cho sôi động
Bài toán tháp Hà Nội EmptyMon Jun 10, 2013 2:27 pm by ducanhle1993

» Suy ngẫm sau một tháng học quân sự!
Bài toán tháp Hà Nội EmptyMon Jun 10, 2013 2:18 pm by ducanhle1993

» giúp các em tư vấn chọn ngành học
Bài toán tháp Hà Nội EmptyMon Jun 10, 2013 2:15 pm by ducanhle1993

» Thac mac
Bài toán tháp Hà Nội EmptySat Jul 28, 2012 10:06 pm by chipcoiga

» Tin Hot về bí thư Nguyễn Phước Trinh
Bài toán tháp Hà Nội EmptySun Jul 15, 2012 10:30 am by ducanhle1993

» Aó đồng phục
Bài toán tháp Hà Nội EmptyMon Jun 11, 2012 2:08 pm by hero.93

» Cảm xúc tràn về
Bài toán tháp Hà Nội EmptyWed May 30, 2012 6:48 pm by chipcoiga

» Ôi Đại Học
Bài toán tháp Hà Nội EmptyTue May 01, 2012 8:36 pm by member

» 4/2012: Báo cáo tình hình hiện nay nào các bạn
Bài toán tháp Hà Nội EmptySun Apr 22, 2012 8:28 pm by member

» mấy e thử lin này tham khao phương pháp làm trắc nghiệm nha
Bài toán tháp Hà Nội EmptySat Apr 21, 2012 10:25 am by ducanhle1993

» Đồng hương Quảng Trị
Bài toán tháp Hà Nội EmptyMon Apr 02, 2012 3:33 pm by thanhbinhqt1993

» [a2vdo] BAN nick lovelanthu10 trong vòng 7 ngày
Bài toán tháp Hà Nội EmptyThu Mar 08, 2012 1:00 pm by chipcoiga

» giới thiệu về ngành Y học dự phòng
Bài toán tháp Hà Nội EmptyWed Feb 22, 2012 8:35 pm by chipcoiga

Top posters
chipcoiga (481)
Bài toán tháp Hà Nội Vote_lcapBài toán tháp Hà Nội Voting_barBài toán tháp Hà Nội Vote_rcap 
thanhbinhqt1993 (283)
Bài toán tháp Hà Nội Vote_lcapBài toán tháp Hà Nội Voting_barBài toán tháp Hà Nội Vote_rcap 
congchung1993 (150)
Bài toán tháp Hà Nội Vote_lcapBài toán tháp Hà Nội Voting_barBài toán tháp Hà Nội Vote_rcap 
ducanhle1993 (141)
Bài toán tháp Hà Nội Vote_lcapBài toán tháp Hà Nội Voting_barBài toán tháp Hà Nội Vote_rcap 
lovemyzip (69)
Bài toán tháp Hà Nội Vote_lcapBài toán tháp Hà Nội Voting_barBài toán tháp Hà Nội Vote_rcap 
A2yeu_93 (57)
Bài toán tháp Hà Nội Vote_lcapBài toán tháp Hà Nội Voting_barBài toán tháp Hà Nội Vote_rcap 
sexxy_gjrl...0h_sexxy (51)
Bài toán tháp Hà Nội Vote_lcapBài toán tháp Hà Nội Voting_barBài toán tháp Hà Nội Vote_rcap 
nhoc_sock_pro (48)
Bài toán tháp Hà Nội Vote_lcapBài toán tháp Hà Nội Voting_barBài toán tháp Hà Nội Vote_rcap 
lovelanthu10 (41)
Bài toán tháp Hà Nội Vote_lcapBài toán tháp Hà Nội Voting_barBài toán tháp Hà Nội Vote_rcap 
winwin (34)
Bài toán tháp Hà Nội Vote_lcapBài toán tháp Hà Nội Voting_barBài toán tháp Hà Nội Vote_rcap 

Tìm kiếm
 
 

Display results as :
 


Rechercher Advanced Search

May 2024
SunMonTueWedThuFriSat
   1234
567891011
12131415161718
19202122232425
262728293031 

Calendar Calendar


You are not connected. Please login or register

Xem chủ đề cũ hơn Xem chủ đề mới hơn Go down  Thông điệp [Trang 1 trong tổng số 1 trang]

1Bình thường Bài toán tháp Hà Nội Fri Jul 02, 2010 8:41 pm

chipcoiga

chipcoiga
Admin
Admin
Ai Thích Thì Chạy Thử Nhé!



program thaphanoi;
Uses crt, dos, tienich, videoram, cursor;
type coc=1..3;
hotkey = set of char;
Const Xcot:array[coc]of byte =(17,41,65);
kitu=#220; SpeedMenu=200;
Max=11; Speed_hieu_ung=30;
MinSpeed=3; MaxSpeed=200; StepSpeed=3;
Tencoc:array[coc]of char = ( '1' , '2' , '3' );
Var i,j:integer;

DK : array[coc, 0..max] of byte;
docao : array[coc]of byte;
timedelay, Ycot, maudia, sodia : integer;
tucot ,toicot : coc;

gio, phut, giay, per, sec : word;
time : integer;

Y_thongbao, nhap_gi : byte;

hangmenu, dongho, chay_menu : string;
st_nhap, st_hdn : string;
so_nhap : integer;
{st_dieukhien st_huongdannhap }
BamPhim, ch : char;
pos_menu, solan :word;

Dung, tamdung, co_nhap, nguoidung, restart:boolean;
dieukhien, dk_thoat : boolean;

{************** Khoi tao gia tri ban dau *****************}
Procedure gan_gia_tri;
Begin solan:=0; timedelay:=MinSpeed*10;
maudia:=5; sodia:=5;
Ycot:=11+sodia; tamdung:=false; dung:=false; restart:=false;
gettime(gio,phut,giay,per); sec:=giay;
co_nhap:=false; dieukhien:=false; nhap_gi:=0; nguoidung:=false;
Y_thongbao:=Ycot-sodia-2;

hangmenu:=' '+'Phim tat: (B)at dau, (D)ung, (T)am dung, (N)hanh hon,'
+'(C)ham hon, Chon so (L)uong dia, Chon (M)au dia, (R)estart,'
+' Tu cha(y), Dieu (k)hien, Nguoi Dun(g) Di Chuyen ' ;
chay_menu:=copy(hangmenu,1,72);
pos_menu:=length(chay_menu)+1;
End;

procedure in_dia(c:coc); Forward; {khai bao thu tuc nay truoc viet lenh sau}
procedure chaydongho; Forward;

{ Phan Giao Dien }
procedure hienthi;
var i,j,k,l:byte;
Begin
i:=39; j:=41; k:=12; l:=12; tcl(9);tbg(1);
repeat
tonen(i,j,k,l,trang);
i:=i-3; j:=j+3;
k:=k-1; l:=l+1;
if k<=1 then k:=1;
if l>=25 then l:=25;
delay(speed_hieu_ung);
until (i<1)or(j>80)or (keypressed);
tonen(1,80,1,25,trang);
End;

procedure hangtren_hangduoi;
const TenThu:array[0..6]of string[12]= (' Chu nhat',' Thu hai',
' Thu ba',' Thu tu',' Thu nam',' Thu sau',' Thu bay');
Function chu(so:word):string;
var s:string;
begin
str(so,s); chu:=s;
end;
Var nam,thang,ngay,thu:word;
st,hd:string;
i:byte;
Begin getdate(nam,thang,ngay,thu);

st:=TenThu[thu]+', ngay '+chu(ngay)+' thang '+chu(thang)+' nam '+chu(nam);
for i:=length(st) to 80 do st:=st+' ';

hd:=' TG: Pham Thanh Binh - Khoa CNTT - DHCT ';

tbg(4);tonen(1,2,1,25,trang); tonen(1,80,1,1,trang);
tonen(79,80,1,25,trang); tonen(1,80,25,25,trang);
tcl(15);
for i:=1 to 78 do
begin
gotoxy(i,1);write(st[i]);
gotoxy(78-i,25);write(hd[78-i]);
delay(speed_hieu_ung div 5);
end;
chaydongho;
End;

procedure gioithieu;
Begin
tcl(10); tbg(1);
gotoxy(30,2);write('TRO CHOI THAP HA NOI');
tcl(7);
gotoxy(4,3);write('Noi dung : Chuyen n dia tu cot ',tencoc[1],' sang cot ',tencoc[2],' dung cot ',tencoc[3],
' lam cot trung gian');
gotoxy(4,4);write('Theo qui tac : - Moi lan chi chuyen 1 dia va la dia tren cung');
gotoxy(4,5);write(' - Dia lon luon nam duoi dia nho');
end;

Procedure khong_gian_dia;
var i:byte;
Begin i:=6; tbg(0);
repeat tonen(i-1,i,Ycot-sodia-4,Ycot+1,trang);
delay(speed_hieu_ung div 2); i:=i+2;
until i>76;
tcl(15); kengang(5,76,Ycot+1,don);{ke 1 duong ngang 1 net}
For i:=1 to 3 do
Begin gotoxy(Xcot[i]-2,Ycot+1);write('Cot ',tencoc[i]); end;{ghi ten 3 cot}
End;

procedure batdau;
Begin
hienthi; hangtren_hangduoi; gioithieu; khong_gian_dia;
end;
{ Het phan giao dien }

{***************** Thoat chuong trinh *****************}
Procedure thoat;
var ch:char;
i:byte;
Begin
inputscr(scr);
tonen(20,60,8,12,trang+nen7+mau15);
kekhung(20,60,8,12,kep+nen7+mau15);
setcl(22,62,13,13,Bài toán tháp Hà Nội Icon_cool; setcl(61,62,9,13,Bài toán tháp Hà Nội Icon_cool;

tbg(7);tcl(15);
td(25,10);write('Ban muon thoat chuong trinh. (Y/N)');
normalcursor;
repeat ch:=upcase(readkey); until ch in ['Y','N',#27];
if ch='Y' then
begin
tbg(0);tcl(7);
For i:=1 to 24 do
begin
td(1,i);
writeln('':80);
delay(speed_hieu_ung);
end;
cls; halt;
end;
hidecursor; outputscr(scr);
end;
{ *********** Xu li nhap *****************}
Procedure nhap;
Begin
If bamphim in ['0'..'9'] then
begin
if length(st_nhap)>=2 then delete(St_nhap,1,1);
st_nhap:=st_nhap + bamphim;

tbg(0);tcl(7); gotoxy(5, Y_thongbao-1);
write(st_hdn,st_nhap:2);
end;
if bamphim=#8 then
begin
if length(st_nhap)>=1 then delete(st_nhap,length(st_nhap),1);
tbg(0);tcl(7); gotoxy(5,Y_thongbao-1); write(st_hdn,st_nhap:2);
end;
End;

{ *********** Tao & write string gio:phut: giay *************}
procedure chaydongho;
var st,st1,st3:string[2];
begin
str(phut,st); if length(st)<2 then st :='0'+st;
str(giay,st1);if length(st1)<2 then st1:='0'+st1;
str(gio,st3); if length(st3)<2 then st3:='0'+st3;
textcolor(15); tbg(4);
gotoxy(71,1);write(st3,':',st,':',st1,' ');
end;
{************ Hien dong trang thai ***************************}
Procedure Dongtrangthai;
Begin
gotoxy(5,Ycot+2);tbg(1);tcl(7);
write('Dia:',sodia:2,' - Mau:',maudia:2,' - Toc do:',Timedelay:4);
write(' - So lan di chuyen:',solan:4,' - Dieu khien:',dieukhien:5);
End;
{************** Xu li menu **************************}
Procedure Xulimenu(bamphim:char);
Begin
Restart:=false;
if bamphim='T' then
begin
if tamdung then tamdung:=false else tamdung:=true;
if tamdung then
begin
gotoxy(35,Y_thongbao); tcl(9); tbg(0);
write('Bam phim T de hoat dong tiep');
end
else
begin
gotoxy(35,Y_thongbao); tcl(9); tbg(0);
write(' ');
end;
end;

if bamphim=#27 then
begin
if (co_nhap)and(nhap_gi<>3) then
begin co_nhap:=false; st_nhap:='';
if dieukhien then
begin nhap_gi:=3;co_nhap:=true;end
else
begin
tbg(0);tcl(maudia); gotoxy(5,Y_thongbao-1); write('':72);
end;
end else thoat;
end;


If tamdung=false then
Begin
Case bamphim of
'B': if dung then begin dung:=false; dk_thoat:=true; end;
'N': Begin timedelay:=timedelay-StepSpeed;{nhanh hon}
If timedelay End;
'C': Begin timedelay:=timedelay+StepSpeed; {cham hon}
If TimeDelay>MaxSpeed then TimeDelay:=MaxSpeed;
End;
'L','M','K': begin co_nhap:=true; st_nhap:='';
tbg(0);tcl(maudia); gotoxy(5,Y_thongbao-1); write('':72);
case bamphim of
'L': nhap_gi:=1; {nhap so luong }
'M': nhap_gi:=2; { nhap mau }
'K': begin dieukhien:=true; nhap_gi:=3; end;
{ nhap tucot -> toicot }
end;
end;
'G': begin
nguoidung:=true;
dung:=true;
dieukhien:=true;
end;
'Y': begin
dieukhien:=false; co_nhap:=false;
tbg(0);tcl(maudia); gotoxy(5,Y_thongbao-1); write('':72);
if nguoidung then
begin
nguoidung:=False; dung:=true;
end;
end;
'R':begin restart:=true; dung:=true; end;
#13: begin
val(st_nhap, so_nhap ,i); co_nhap:=false; st_nhap:='';
case nhap_gi of
1: begin
if (so_nhap in[1..11])and(so_nhap<>sodia)then
begin dk_thoat:=true;
dung:=true;
sodia:=so_nhap;
Ycot:=11+sodia; Y_thongbao:=Ycot-sodia-2;
batdau; solan:=0;
gotoxy(35,Y_thongbao);
tbg(0);tcl(10);write('Bam phim B de bat dau chay');
end;
end;
2: if so_nhap in[1..15]then
begin
maudia:=so_nhap;
setcl( 5, 75, Ycot-sodia-1, Ycot,maudia);
end;
3: if dieukhien then co_nhap:=true;
end; {of CASE}

if dieukhien or nguoidung then
begin
co_nhap:=true; nhap_gi:=3;
end;
if co_nhap=False then
begin
tbg(0);tcl(maudia); gotoxy(5,Y_thongbao-1); write('':72);
end;
dongtrangthai;
end;{of #13}
end; {case bamphim}

if co_nhap then
begin
case nhap_gi of
1:st_hdn:='Nhap so luong dia (1 - 11) : N = ';
2:st_hdn:='Nhap mau dia (1 - 15) : ';
3:st_hdn:='Di chuyen dia :(vi du tu cot 1 den cot 2 nhap vao la 12) : ';
else st_hdn:='';
end;
tbg(0);tcl(7); gotoxy(5,Y_thongbao-1); write(st_hdn,st_nhap:2);
nhap;
end;
End;{ if tamdung=false}
if bamphim='D' then dung:=true;
End;

{*************** Xu li toc do chay chuong trinh ************}
Procedure trangthaicho;
Begin
time:=time+1; delay(1); if time>1000 then time:=1;

gettime(gio,phut,giay,per);
If sec<>giay then {chay dong ho}
begin
sec:=giay; chaydongho;
end;
If time mod SpeedMenu =0 then { chay menu }
begin
chay_menu:=chay_menu + hangmenu[pos_menu];
delete(chay_menu,1,1);
if pos_menu>=length(hangmenu)then pos_menu:=1 else inc(pos_menu);
gotoxy(5,Y_thongbao-2);tbg(0);tcl(15);write(chay_menu);
end;
End;
{**************** Thu tuc lam cham tac dung giong Delay ***************}
Procedure lamcham(timedelay:integer; Bo_chuc_nang:hotkey);
Begin
dk_thoat:=false;
repeat
repeat trangthaicho; until keypressed or (time mod timedelay =0 );
bamphim:=#0;
if keypressed then
begin
bamphim:=upcase(readkey);
If not(bamphim in Bo_chuc_nang)then xulimenu(bamphim);
dongtrangthai;
end;
until ( (time mod timedelay=0)or dk_thoat or(dieukhien and(time mod timedelay=0))
) and (tamdung=false)or dung;
End;
{*********************************************************************}
Procedure In_dia(c:coc);
var i,j,x,y:byte;
Begin
For i:=1 to 3 do
For J:=0 to sodia do dk[i,j]:=0;
Ycot:=11+sodia;
tbg(0);tcl(maudia);
tonen(5,75,Ycot-sodia-2,Ycot,trang);
For i:=1 to sodia do
begin delay(Speed_hieu_ung);
gotoxy( Xcot[c] - ((2*i+1)div 2) , Ycot-sodia+i);
For j:=1 to 2*i+1 do write(kitu);
dk[c,sodia-i+1]:=2*i+1;
end;
for i:=1 to 3 do docao[i]:=0;
docao[c]:=sodia;
End;
{*************** Thu tuc in hoac xoa 1 dia tai toa do X,Y**************}
Procedure hien(c: coc ; X,Y: byte; kitu:char);
Var i:byte;
Begin tcl(maudia);tbg(0);
gotoxy( X - (DK[ c,docao[c] ]div 2) , Y );
For i:=1 to dk[c,docao[c]] do write(kitu);
End;


{*************** Phan Di Chuyen Dia ******************}
Procedure len( C ,c2 : coc);
Var i,j,y:byte;
Begin
y:=Ycot - sodia - 1; {Y la hang tren cung can di chuyen len}
i:=Ycot-docao[c];
hien(c ,Xcot[c],i+1 , ' '); {Xoa dia tren cot}
For j:=i downto y do
begin
hien(c,Xcot[c],j,kitu); lamcham(TimeDelay,[]); hien(c, Xcot[c],j, ' ');
if dung then exit;
end;
End;

Procedure xuong( c2,C : coc);
Var i,y1,y2:byte;
Begin
y1:=Ycot - sodia - 1;{y1 la hang tren (hang bat dau)}
y2:=Ycot-docao[c]; {y2 la hang duoi}
For i:=y1 to y2 do
begin
hien(c2,Xcot[c],i,kitu); lamcham(TimeDelay,[]); hien(c2,Xcot[c], i, ' ');
if dung then exit;
end;
hien(c2,Xcot[c],i,kitu);
End;

Procedure Xoa(X,Y:byte);
Var I:byte;
Begin gotoxy(X,Y); tbg(0); write(' '); End;

Procedure Phai(c1,c2: coc);
Var i,y:byte;
Begin
y:=Ycot - sodia - 1;
Xoa(Xcot[c1]-(dk[c1,docao[c1]]div 2),y);
i:=Xcot[c1];
Repeat
i:=i+2;
hien(c1,i,y,kitu);
lamcham(TimeDelay,[]);
Xoa(i-(dk[c1,docao[c1]]div 2),y);
if dung then exit;
until i>=Xcot[c2];
hien(c1,Xcot[c2],y,kitu);
End;

Procedure Trai(c1,c2: coc);
Var i,y:byte;
Begin
y:=Ycot - sodia - 1;
i:=Xcot[c1];
Repeat
hien(c1,i,y,kitu);
lamcham(TimeDelay,[]);
Xoa(i+(dk[c1,docao[c1]]div 2)-1,y);
i:=i-2;
if dung then exit;
until i<=Xcot[c2];
hien(c1,Xcot[c2],y,kitu);
End;

{**************** Het Phan Di Chuyen Dia ******************}

Procedure DICHCHUYEN(Ndia:byte; cot1,cot2,cot3:coc);
Begin
if dung then exit;
If ndia=1 then
Begin
if dieukhien then
Begin
tbg(0);tcl(7);td(5,Y_thongbao-1);
write('Di chuyen dia :(vi du tu cot 1 den cot 2 nhap vao la 12) : ');
repeat
repeat trangthaicho; Until keypressed;
if keypressed then bamphim:=upcase(readkey);

if (bamphim=#13)and(nhap_gi=3)and(length(st_nhap)>=2) then
begin val(st_nhap[1],tucot,i);
val(St_nhap[2],toicot,i);

gotoxy(25,Y_thongbao);tbg(0);tcl(1);write(' ');
{xoa dong chu di chuyen sai}

if (tucot<>cot1)or(toicot<>cot2)then
begin
gotoxy(25,Y_thongbao);tbg(0);tcl(10);
write('Ban di chuyen sai');
end;
end;
xulimenu(bamphim); dongtrangthai;
until (bamphim='Y')or( (tucot=cot1)and(toicot=cot2)and(bamphim=#13) )
or (dieukhien=false)or dung;

tbg(0);tcl(7);td(5,Y_thongbao-1); write('':70);
{Xoa cau nhap dia}
if dung then exit;
End;{Dieukhien}

inc(solan);
len(cot1,cot2);
if cot2>cot1 then phai(cot1,cot2)else trai(cot1,cot2);
lamcham(TimeDelay,[]); lamcham(TimeDelay,[]);
xuong(cot1,cot2);

inc(docao[cot2]); {tang do cao cot toi}
DK[cot2,docao[cot2]]:=DK[cot1,docao[cot1]];
dk[cot1,docao[cot1]]:=0;
dec(docao[cot1]);
dongtrangthai;
end {n=1}
Else
Begin
DICHCHUYEN(Ndia-1, cot1, cot3, cot2);
DICHCHUYEN(1 , cot1, cot2, cot3);
DICHCHUYEN(Ndia-1, cot3, cot2, cot1);
End;
End;

Procedure NguoiDungDiChuyen;
var hople:boolean;
Begin

Repeat

If dung then exit;
tbg(0);tcl(7);td(5,Ycot-sodia-3);
write('Di chuyen dia :(vi du tu cot 1 den cot 2 nhap vao la 12) : ');

gotoxy(30,Ycot-sodia-2);tbg(0); tcl(10);
write(' ');
Repeat
hople:=false;
Repeat
trangthaicho;
If keypressed then
Begin
bamphim:=upcase(readkey);
If bamphim in ['L','M','Y','R','D',#27,#13,#8,'0'..'9'] then
Begin

if (bamphim=#13)and(nhap_gi=3)and(length(st_nhap)>=2) then
Begin
val(st_nhap[1],tucot,i);
val(St_nhap[2],toicot,i);

if (tucot<>toicot)and(docao[tucot]>0)
and ( (DK[ toicot,docao[toicot] ] > dk[ tucot,docao[tucot] ])
and(docao[toicot]>0)
)
then hople:=true;

gotoxy(30,Ycot-sodia-2);tbg(0); tcl(10);
write(' ');

If not hople then
begin
gotoxy(30,Ycot-sodia-2);tbg(0); tcl(10);
write('Di chuyen khong hop le');
end;
End;
xulimenu(bamphim);


dongtrangthai;
End;
End;{keypressed}
Until hople or dung or dk_thoat or (bamphim in['Y']);

gotoxy(30,Ycot-sodia-2);tbg(0); tcl(10);
write(' ');

if dung then exit;

dk_thoat:=false;

Until hople;

inc(solan);
len(tucot,toicot);
if tucot>toicot then trai(tucot,toicot)else phai(tucot,toicot);
lamcham(TimeDelay,[]); lamcham(TimeDelay,[]);
xuong(tucot,toicot);

inc(docao[toicot]);
DK[toicot,docao[toicot]]:=DK[tucot,docao[tucot]];
dk[tucot,docao[tucot]]:=0;
dec(docao[tucot]);
dongtrangthai;
Until dung or (bamphim in ['Y']);
End;

{ Chuong trinh chinh }

Begin
textmode(co80);clrscr; delay(1500); hidecursor;
gan_gia_tri;
batdau; tcl(5);

Repeat
dongtrangthai; dung:=false; in_dia(1);
If (not restart)and(not dieukhien)and(not nguoidung) then
Begin
gotoxy(35,Ycot-sodia + sodia div 2);
tbg(0);tcl(10);write('Bam phim B de bat dau chay');
Repeat
trangthaicho;
if keypressed then
begin
bamphim:=upcase(readkey);
if bamphim in['M','G','L','N','C','K','Y',#27,'0'..'9',#13,#8]then
xulimenu(bamphim);
dongtrangthai;
end;
until (bamphim in['B','K','G'])or(dung) ;
gotoxy(35,Ycot-sodia + sodia div 2);
tbg(0);tcl(10);write(' ');
{Xoa cau bam phim B}
End;
restart:=false;
If nguoidung then nguoidungdichuyen else Dichchuyen(sodia,1,2,3);
solan:=0;

if not dung then
begin
gotoxy(25,Ycot-sodia-1 );
tbg(0);tcl(10);write('Di chuyen xong bam phim bat ky de chay lai');
repeat trangthaicho; until keypressed;
if keypressed then ch:=readkey;
if ch=#27 then thoat;
gotoxy(25,Ycot-sodia -1);
tbg(0);tcl(10);write(' ');
tbg(0);tcl(maudia); gotoxy(5,Ycot-sodia-3); write(' ':72);
end;

Until False;
End.



--
https://a2vdo.forum.st/

https://a2vdo.forum.st/

2Bình thường Re: Bài toán tháp Hà Nội Sat Jul 03, 2010 9:15 am

kiss_kisslove2010


Sơ sinh
Sơ sinh
ua! rua lam rang ma dem vo trong pascal vay ha!!!??? Bài toán tháp Hà Nội 205770

3Bình thường Re: Bài toán tháp Hà Nội Tue Jul 20, 2010 7:28 am

thanhbinhqt1993

thanhbinhqt1993
Đại học
Đại học
copy dem dan vo^

http://www.0.facebook.com/pham.thanhbinh.50

4Bình thường Re: Bài toán tháp Hà Nội Wed Jul 21, 2010 9:38 am

chipcoiga

chipcoiga
Admin
Admin
coppy vô notepas sau đó lưu với đuôi *.pas với * là tên tệp, dán tệp đó vào trong thư mục BIN, thư mục con là UNIT! ok nhé. rùi mở bằng pascal là xong hi!

https://a2vdo.forum.st/

5Bình thường Re: Bài toán tháp Hà Nội Thu Jul 22, 2010 8:12 am

thanhbinhqt1993

thanhbinhqt1993
Đại học
Đại học
ẩứa đó

http://www.0.facebook.com/pham.thanhbinh.50

6Bình thường Re: Bài toán tháp Hà Nội Thu Jul 22, 2010 8:41 pm

chipcoiga

chipcoiga
Admin
Admin
he!

https://a2vdo.forum.st/

7Bình thường Re: Bài toán tháp Hà Nội Mon Jul 26, 2010 9:53 am

thanhbinhqt1993

thanhbinhqt1993
Đại học
Đại học
co chi ma he` Bài toán tháp Hà Nội At

http://www.0.facebook.com/pham.thanhbinh.50

8Bình thường Re: Bài toán tháp Hà Nội Tue Jul 27, 2010 9:26 am

nhoc_sock_pro

nhoc_sock_pro
Tiểu học
Tiểu học
acaaaaaaaaa. các cao thủ đừng đánh nhau nhé

9Bình thường Bản text tháp hà nội mới nhất Tue Jul 27, 2010 9:30 am

winwin

winwin
Mầm non
Mầm non
Code:
program thaphn;
uses crt, graph;
type
coc = 1..3;
const
n=4;
yorg =20;
xorg : array [coc] of integer = (13, 40, 67);
time = 60;
time2 = 40;
var
dk : array[1..n, coc] of integer;
docao: array[coc] of integer;
i: integer;
procedure tre(t: integer);
begin
gotoxy(43, 4);
delay(t);
end;
procedure move(c1, c2 :integer);
var
i,j,x: integer;
begin
for j:=1 to 4 do
begin
x:= xorg[c1] -dk[docao[c1], c1];
gotoxy(x, yorg-n-j-1);
for i:=1 to 2*dk[docao[c1], c1] +1 do write(#219);
tre(time);
gotoxy(x, yorg-n-j-1);
for i:=1 to 2*dk[docao[c1], c1] +1 do write('  ');
tre(time);
end;
end;
procedure moved(c1, c2: integer);
var
i,j,x : integer;
begin for j:=4 downto 1 do begin
x:= xorg[c2] -dk[docao[c1], c1];
gotoxy(x, yorg-n-j-i-1);
for i:=1 to 2*dk[docao[c1], c1] +1 do write(#219);
tre(time);
gotoxy(x, yorg-n-j-1);
for i:=1 to 2*dk[docao[c1], c1]+1 do write(#219);
tre(time);
end;
end;
procedure mover(c1,c2: integer);
var i,x,xx: integer;
begin
x:= xorg[c1];
while x <= xorg[c2] do
begin
xx:= xorg[c1]-dk[docao[c1], c1] +x-xorg[c1];
gotoxy(xx, yorg-n-5);
for i:=1 to 2*dk[docao[c1], c1] +1 do write(#219);
tre(time2);
gotoxy(xx, yorg-n-5);
for i:=1 to 2*dk[docao[c1], c1] +1 do write('  ');
tre(time2);
x:=x+2;
end;
end;
procedure movel(c1,c2: integer);
var
i,j,x,xx: integer;
begin
x:=xorg[c1];
while X >=xorg[c2] do
begin
xx:=xorg[c1] -dk[docao[c1],c1] +x-xorg[c1];
gotoxy(xx, yorg-n-5);
for i:=1 to 2*dk[docao[c1], c1] +1 do write(#219);
tre(time2);
gotoxy(xx, yorg-n-5);
for i:=1 to 2*dk[docao[c1], c1] + 1 do write('  ');
tre(time2);
x:=x-2;
end;
end;
procedure dichchuyen(n,c1,c2,c3: integer);
var x: integer;
begin
if n=1 then
begin
x:=xorg[c1]-dk[docao[c1],c1];
gotoxy (x, yorg-docao[c1]+1);
for i:=1 to 2*dk[docao[c1],c1]+1 do
begin
if docao[c1]=1 then
begin
write('-');
if i=dk[docao[c1],c1] then write(#193);
end
else write('  ');
end;
gotoxy(xorg[c1], yorg-docao[c1]+1);
write(#179); tre(time);
move(c1,c2);
if c2>c1 then mover(c1,c2) else movel(c1,c2);
moved(c1,c2);
docao[c2]:= docao[c2]+1;
dk[docao[c2], c2]:=dk[docao[c1],c1];
dk[docao[c1],c1]:=0;
docao[c1]:=docao[c1]-1;
x:=xorg[c2]-dk[docao[c2],c2];
gotoxy(x, yorg-docao[c2]+1);
for i:=1 to 2*dk[docao[c2],c2]+1 do write(#219);
delay(200);
end
else
begin
dichchuyen(n-1,c1,c3,c2);
dichchuyen(1,c1,c2,c3);
dichchuyen(n-1,c3,c2,c1);
gotoxy(40,4);
end;
end;
begin
clrscr;
gotoxy(35,4); write('a2vdo.forum.st:  THAP HA NOI');
gotoxy(4, yorg-n+4);
write('----------------');
writeln('------------------------');
gotoxy(xorg[1], yorg-n); write(#179);
gotoxy(xorg[1]-1, yorg-n+1); write('    ',#219,#219,#219,'    ');
gotoxy(xorg[1]-2, yorg-n+2); write('  ',#219,#219,#219,#219,#219,'  ');
gotoxy(xorg[1]-3, yorg-n+3); write(' ',#219,#219,#219,#219,#219,#219,#219,' ');
gotoxy(xorg[1]-4, yorg-n+4); write('',#219,#219,#219,#219,#219,#219,#219,#219#219,'');
for i:=1 to n do
begin gotoxy(xorg[2], yorg-n+i);
write(#179);
end;
for i:=1 to n do
begin
gotoxy(xorg[3], yorg-n+i);
write(#179);
end;
docao[1]:=n; docao[2]:=0; docao[3]:=0;
for i:=1 to n do dk[i,1]:= n-i+1;
for i:=1 to n do dk[i,2]:= 0;
for i:=1 to n do dk[i,3]:= 0;
gotoxy(22,24); write(' Nhan Ctrl_C de dung lai!');
gotoxy(43,4);
repeat
delay(1000); dichchuyen(n,1,2,3);
delay(1000); dichchuyen(n,2,3,1);
delay(1000); dichchuyen(n,3,1,2);
until keypressed;
end.
 


đã chạy thử. yêu cầu máy phải có thư viện crt học đang dùng pascal phiên bản 5

10Bình thường Bản text tháp hà nội mới nhất Tue Jul 27, 2010 9:32 am

winwin

winwin
Mầm non
Mầm non
program thaphn;
uses crt, graph;
type
coc = 1..3;
const
n=4;
yorg =20;
xorg : array [coc] of integer = (13, 40, 67);
time = 60;
time2 = 40;
var
dk : array[1..n, coc] of integer;
docao: array[coc] of integer;
i: integer;
procedure tre(t: integer);
begin
gotoxy(43, 4);
delay(t);
end;
procedure move(c1, c2 :integer);
var
i,j,x: integer;
begin
for j:=1 to 4 do
begin
x:= xorg[c1] -dk[docao[c1], c1];
gotoxy(x, yorg-n-j-1);
for i:=1 to 2*dk[docao[c1], c1] +1 do write(#219);
tre(time);
gotoxy(x, yorg-n-j-1);
for i:=1 to 2*dk[docao[c1], c1] +1 do write(' ');
tre(time);
end;
end;
procedure moved(c1, c2: integer);
var
i,j,x : integer;
begin for j:=4 downto 1 do begin
x:= xorg[c2] -dk[docao[c1], c1];
gotoxy(x, yorg-n-j-i-1);
for i:=1 to 2*dk[docao[c1], c1] +1 do write(#219);
tre(time);
gotoxy(x, yorg-n-j-1);
for i:=1 to 2*dk[docao[c1], c1]+1 do write(#219);
tre(time);
end;
end;
procedure mover(c1,c2: integer);
var i,x,xx: integer;
begin
x:= xorg[c1];
while x <= xorg[c2] do
begin
xx:= xorg[c1]-dk[docao[c1], c1] +x-xorg[c1];
gotoxy(xx, yorg-n-5);
for i:=1 to 2*dk[docao[c1], c1] +1 do write(#219);
tre(time2);
gotoxy(xx, yorg-n-5);
for i:=1 to 2*dk[docao[c1], c1] +1 do write(' ');
tre(time2);
x:=x+2;
end;
end;
procedure movel(c1,c2: integer);
var
i,j,x,xx: integer;
begin
x:=xorg[c1];
while X >=xorg[c2] do
begin
xx:=xorg[c1] -dk[docao[c1],c1] +x-xorg[c1];
gotoxy(xx, yorg-n-5);
for i:=1 to 2*dk[docao[c1], c1] +1 do write(#219);
tre(time2);
gotoxy(xx, yorg-n-5);
for i:=1 to 2*dk[docao[c1], c1] + 1 do write(' ');
tre(time2);
x:=x-2;
end;
end;
procedure dichchuyen(n,c1,c2,c3: integer);
var x: integer;
begin
if n=1 then
begin
x:=xorg[c1]-dk[docao[c1],c1];
gotoxy (x, yorg-docao[c1]+1);
for i:=1 to 2*dk[docao[c1],c1]+1 do
begin
if docao[c1]=1 then
begin
write('-');
if i=dk[docao[c1],c1] then write(#193);
end
else write(' ');
end;
gotoxy(xorg[c1], yorg-docao[c1]+1);
write(#179); tre(time);
move(c1,c2);
if c2>c1 then mover(c1,c2) else movel(c1,c2);
moved(c1,c2);
docao[c2]:= docao[c2]+1;
dk[docao[c2], c2]:=dk[docao[c1],c1];
dk[docao[c1],c1]:=0;
docao[c1]:=docao[c1]-1;
x:=xorg[c2]-dk[docao[c2],c2];
gotoxy(x, yorg-docao[c2]+1);
for i:=1 to 2*dk[docao[c2],c2]+1 do write(#219);
delay(200);
end
else
begin
dichchuyen(n-1,c1,c3,c2);
dichchuyen(1,c1,c2,c3);
dichchuyen(n-1,c3,c2,c1);
gotoxy(40,4);
end;
end;
begin
clrscr;
gotoxy(35,4); write('a2vdo.forum.st: THAP HA NOI');
gotoxy(4, yorg-n+4);
write('----------------');
writeln('------------------------');
gotoxy(xorg[1], yorg-n); write(#179);
gotoxy(xorg[1]-1, yorg-n+1); write(' ',#219,#219,#219,' ');
gotoxy(xorg[1]-2, yorg-n+2); write(' ',#219,#219,#219,#219,#219,' ');
gotoxy(xorg[1]-3, yorg-n+3); write(' ',#219,#219,#219,#219,#219,#219,#219,' ');
gotoxy(xorg[1]-4, yorg-n+4); write('',#219,#219,#219,#219,#219,#219,#219,#219#219,'');
for i:=1 to n do
begin gotoxy(xorg[2], yorg-n+i);
write(#179);
end;
for i:=1 to n do
begin
gotoxy(xorg[3], yorg-n+i);
write(#179);
end;
docao[1]:=n; docao[2]:=0; docao[3]:=0;
for i:=1 to n do dk[i,1]:= n-i+1;
for i:=1 to n do dk[i,2]:= 0;
for i:=1 to n do dk[i,3]:= 0;
gotoxy(22,24); write(' Nhan Ctrl_C de dung lai!');
gotoxy(43,4);
repeat
delay(1000); dichchuyen(n,1,2,3);
delay(1000); dichchuyen(n,2,3,1);
delay(1000); dichchuyen(n,3,1,2);
until keypressed;
end.

11Bình thường yêu cầu Tue Jul 27, 2010 9:34 am

winwin

winwin
Mầm non
Mầm non
yêu cầu pascal hoặc có thư viên crt

12Bình thường Re: Bài toán tháp Hà Nội Tue Jul 27, 2010 9:37 am

lovemyzip

lovemyzip
Tiểu học
Tiểu học
Code:
program thaphn;
uses crt, graph;
type
coc = 1..3;
const
n=4;
yorg =20;
xorg : array [coc] of integer = (13, 40, 67);
time = 60;
time2 = 40;
var
dk : array[1..n, coc] of integer;
docao: array[coc] of integer;
i: integer;
procedure tre(t: integer);
begin
gotoxy(43, 4);
delay(t);
end;
procedure move(c1, c2 :integer);
var
i,j,x: integer;
begin
for j:=1 to 4 do
begin
x:= xorg[c1] -dk[docao[c1], c1];
gotoxy(x, yorg-n-j-1);
for i:=1 to 2*dk[docao[c1], c1] +1 do write(#219);
tre(time);
gotoxy(x, yorg-n-j-1);
for i:=1 to 2*dk[docao[c1], c1] +1 do write('  ');
tre(time);
end;
end;
procedure moved(c1, c2: integer);
var
i,j,x : integer;
begin for j:=4 downto 1 do begin
x:= xorg[c2] -dk[docao[c1], c1];
gotoxy(x, yorg-n-j-i-1);
for i:=1 to 2*dk[docao[c1], c1] +1 do write(#219);
tre(time);
gotoxy(x, yorg-n-j-1);
for i:=1 to 2*dk[docao[c1], c1]+1 do write(#219);
tre(time);
end;
end;
procedure mover(c1,c2: integer);
var i,x,xx: integer;
begin
x:= xorg[c1];
while x <= xorg[c2] do
begin
xx:= xorg[c1]-dk[docao[c1], c1] +x-xorg[c1];
gotoxy(xx, yorg-n-5);
for i:=1 to 2*dk[docao[c1], c1] +1 do write(#219);
tre(time2);
gotoxy(xx, yorg-n-5);
for i:=1 to 2*dk[docao[c1], c1] +1 do write('  ');
tre(time2);
x:=x+2;
end;
end;
procedure movel(c1,c2: integer);
var
i,j,x,xx: integer;
begin
x:=xorg[c1];
while X >=xorg[c2] do
begin
xx:=xorg[c1] -dk[docao[c1],c1] +x-xorg[c1];
gotoxy(xx, yorg-n-5);
for i:=1 to 2*dk[docao[c1], c1] +1 do write(#219);
tre(time2);
gotoxy(xx, yorg-n-5);
for i:=1 to 2*dk[docao[c1], c1] + 1 do write('  ');
tre(time2);
x:=x-2;
end;
end;
procedure dichchuyen(n,c1,c2,c3: integer);
var x: integer;
begin
if n=1 then
begin
x:=xorg[c1]-dk[docao[c1],c1];
gotoxy (x, yorg-docao[c1]+1);
for i:=1 to 2*dk[docao[c1],c1]+1 do
begin
if docao[c1]=1 then
begin
write('-');
if i=dk[docao[c1],c1] then write(#193);
end
else write('  ');
end;
gotoxy(xorg[c1], yorg-docao[c1]+1);
write(#179); tre(time);
move(c1,c2);
if c2>c1 then mover(c1,c2) else movel(c1,c2);
moved(c1,c2);
docao[c2]:= docao[c2]+1;
dk[docao[c2], c2]:=dk[docao[c1],c1];
dk[docao[c1],c1]:=0;
docao[c1]:=docao[c1]-1;
x:=xorg[c2]-dk[docao[c2],c2];
gotoxy(x, yorg-docao[c2]+1);
for i:=1 to 2*dk[docao[c2],c2]+1 do write(#219);
delay(200);
end
else
begin
dichchuyen(n-1,c1,c3,c2);
dichchuyen(1,c1,c2,c3);
dichchuyen(n-1,c3,c2,c1);
gotoxy(40,4);
end;
end;
begin
clrscr;
gotoxy(35,4); write('a2vdo.forum.st:  THAP HA NOI');
gotoxy(4, yorg-n+4);
write('----------------');
writeln('------------------------');
gotoxy(xorg[1], yorg-n); write(#179);
gotoxy(xorg[1]-1, yorg-n+1); write('    ',#219,#219,#219,'    ');
gotoxy(xorg[1]-2, yorg-n+2); write('  ',#219,#219,#219,#219,#219,'  ');
gotoxy(xorg[1]-3, yorg-n+3); write(' ',#219,#219,#219,#219,#219,#219,#219,' ');
gotoxy(xorg[1]-4, yorg-n+4); write('',#219,#219,#219,#219,#219,#219,#219,#219#219,'');
for i:=1 to n do
begin gotoxy(xorg[2], yorg-n+i);
write(#179);
end;
for i:=1 to n do
begin
gotoxy(xorg[3], yorg-n+i);
write(#179);
end;
docao[1]:=n; docao[2]:=0; docao[3]:=0;
for i:=1 to n do dk[i,1]:= n-i+1;
for i:=1 to n do dk[i,2]:= 0;
for i:=1 to n do dk[i,3]:= 0;
gotoxy(22,24); write(' Nhan Ctrl_C de dung lai!');
gotoxy(43,4);
repeat
delay(1000); dichchuyen(n,1,2,3);
delay(1000); dichchuyen(n,2,3,1);
delay(1000); dichchuyen(n,3,1,2);
until keypressed;
end.
Cái ni được nè

13Bình thường Re: Bài toán tháp Hà Nội Sat Jul 31, 2010 8:02 am

thanhbinhqt1993

thanhbinhqt1993
Đại học
Đại học
Kinh

http://www.0.facebook.com/pham.thanhbinh.50

Sponsored content


Xem chủ đề cũ hơn Xem chủ đề mới hơn Về Đầu Trang  Thông điệp [Trang 1 trong tổng số 1 trang]

Permissions in this forum:
Bạn không có quyền trả lời bài viết

 
  •  

Create a forum on Forumotion | ©phpBB | Free forum support | Báo cáo lạm dụng | Thảo luận mới nhất