/* tour of hanai */
#include<stdio.h>
#include<conio.h>
void main()
{
int n,
char sn='l';
char in='c';
char dn='r';
honai();
printf("Enter number of disks");
scanf("%d",&n);
printf("The tour of honai problem with%d disks",n);
honai(n,sn,in,dn);
printf("\n");
}
honai(int n,int sn,int in,int dn)
{
int n;
char sndl,indl,dndl;
{
if(n!=0)
honai(n-1,sndl,dndl,indl);
printf("move disk %d from %c to %c",n,sndl,dndl);
honai(n-1,indl,sndl,dndl);
}
}
#include<stdio.h>
#include<conio.h>
void main()
{
int n,
char sn='l';
char in='c';
char dn='r';
honai();
printf("Enter number of disks");
scanf("%d",&n);
printf("The tour of honai problem with%d disks",n);
honai(n,sn,in,dn);
printf("\n");
}
honai(int n,int sn,int in,int dn)
{
int n;
char sndl,indl,dndl;
{
if(n!=0)
honai(n-1,sndl,dndl,indl);
printf("move disk %d from %c to %c",n,sndl,dndl);
honai(n-1,indl,sndl,dndl);
}
}
No comments:
Post a Comment