Docstoc

TOWER

Document Sample
TOWER Powered By Docstoc
					/* Write a Program for tower of Hanoi   */
void hanoi_tower(char,char,char,int);
void main()
 {
   int n;
   clrscr();
   printf("Enter Number of disc : ");
   scanf("%d",&n);
   hanoi_tower('A','B','C',n);
   getch();
 }


void hanoi_tower(char t1,char t2,char t3,int n)
   {
    if(n==1)
     {
      printf("\n\t\tMove disc from %c to %c.",t1,t3);
     }
    else
     {
       hanoi_tower(t1,t3,t2,n-1);
       hanoi_tower(t1,t2,t3,1);
       hanoi_tower(t2,t1,t3,n-1);
     }
 }

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:50
posted:3/21/2010
language:English
pages:1
Description: gtu-mca.blogspot.com