procedure borj(n:integer;from,help,to:char);
begin
if n=1 then
writeln('move mohre from ',from,'to',to)
else begin
borj(n-1,from,to,help)
writeln('move a mohre from ' , from ,'to',to);
borj(n-1,help,from,to)
end;{else}
end;
بجاي begin و end آكولاد باز و بسته بزار .
براي writeln هم cout \n رو بزن كه يه خط بره پايين .
ميله وسطي help هست . ميله اي كه سمت چپ هست ديكس ها توش هستند .
بكمك help هر بار ديسك ها رو جايگزين مي كني .
Joined: 27 Nov 2004 Posts: 1232 Location: www.parsx.com
Posted: Mon May 29, 2006 2:14 pm Post subject:
این به زبان C هستش :
void borj(int n ,char from,char help,char to)
{
if (n==1)
printf("move mohre from %c to %c ",from,to) ;
else {
borj(n-1,from,to,help);
printf("move a mohre from %c to %c \n " , from ,to);
borj(n-1,help,from,to);
}
}
و این به زبان ++C :
void borj(int n ,char from,char help,char to)
{
if (n==1)
cout<<"move mohre from "<<from<<"to"<<to ;
else {
borj(n-1,from,to,help);
cout<<"move a mohre from " << from<<" to "<<to<<"\n";
borj(n-1,help,from,to);
}
}
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum