دلفي تعليم
هل تريد التفاعل مع هذه المساهمة؟ كل ما عليك هو إنشاء حساب جديد ببضع خطوات أو تسجيل الدخول للمتابعة.

قلعة هانوي

اذهب الى الأسفل

قلعة هانوي Empty قلعة هانوي

مُساهمة  mah11 20/7/2013, 7:39 pm

قلعة هانوي

الكود:

program tour_de_hanoi;
uses crt;
var i,x,y,a,b,m:integer;

procedure disque3(i,m:integer);
begin
 gotoxy(m+4,17); for i:=1 to 20 do write('*');
 gotoxy(m+4,19); for i:=1 to 20 do write('*');
 gotoxy(m+4,18); write('*'); gotoxy(m+23,18); write('*');
 gotoxy(m+11,18); write('Disque3');
end;
procedure disque2(i,a,b:integer);
begin
 gotoxy(a+6,b+14); for i:=1 to 16 do write('*');
 gotoxy(a+6,b+16); for i:=1 to 16 do write('*');
 gotoxy(a+6,b+15); write('*'); gotoxy(a+21,b+15); write('*');
 gotoxy(a+11,b+15); write('Disque2');
end;
procedure disque1(i,x,y:integer);
begin
 gotoxy(x+8,y+11); for i:=1 to 12 do write('*');
 gotoxy(x+8,y+13); for i:=1 to 12 do write('*');
 gotoxy(x+8,y+12); write('*'); gotoxy(x+19,y+12); write('*');
 gotoxy(x+11,y+12); write('Disque1');
end;

procedure hanoi_pro(i:integer);
begin
 gotoxy(1,20); for i:=1 to 79 do write('*');
 gotoxy(10,21); write('A'); gotoxy(38,21); write('B');
 gotoxy(69,21); write('C');
 disque3(i,m);
 disque2(i,a,b);
 disque1(i,x,y);
end;

var ch:char;
begin
 clrscr;
 x:=0; y:=0;
 a:=0; b:=0; m:=0;
 hanoi_pro(i);    {1}
 readln;
 clrscr;
 x:=25;  y:=6;
 hanoi_pro(x);    {2}
 readln;
 clrscr;
 a:=55; b:=3;
 hanoi_pro(a);    {3}
 readln;
 clrscr;
 x:=55; y:=3;
 hanoi_pro(x);    {4}
 readln;
 clrscr;
 m:=25;
 hanoi_pro(m);    {5}
 readln;
 clrscr;
 x:=0; y:=6;
 hanoi_pro(x);    {6}
 readln;
 clrscr;
 a:=25; b:=0;
 hanoi_pro(a);    {7}
 readln;
 clrscr;
 x:=25; y:=0;
 hanoi_pro(x);    {8}
 gotoxy(32,8); write('Tour de hanoi');
 readln; readln;
end.


mah11
Admin

عدد المساهمات : 364
تاريخ التسجيل : 21/06/2013

https://delph.forumalgerie.net

الرجوع الى أعلى الصفحة اذهب الى الأسفل

الرجوع الى أعلى الصفحة


 
صلاحيات هذا المنتدى:
لاتستطيع الرد على المواضيع في هذا المنتدى