Yarın bu programın nasıl çalıştıgını kaba taslak anlatmam gerek,açıklayabilecek biri varmı kısaca
#include "stdio.h" void hanoi(int,char,char,char); void hanoi(int n,char frompeg,char topeg,char auxpeg) { if(n==1) { printf("\nMove disk 1 from peg %c to peg %c",frompeg,topeg); return; } hanoi(n-1,frompeg,auxpeg,topeg); printf("\nMove disk %d from peg %c to peg %c",n,frompeg,topeg); hanoi(n-1,auxpeg,topeg,frompeg); } main() { int n; printf("<<< Please, enter the number of disks >>> : "); scanf("%d",&n); printf("The Tower of Hanoi involves the moves :\n\n"); hanoi(n,'A','C','B'); return 0;
getch(); }
DH forumlarında vakit geçirmekten keyif alıyor gibisin ancak giriş yapmadığını görüyoruz.
Üye olduğunda özel mesaj gönderebilir, beğendiğin konuları favorilerine ekleyip takibe alabilir ve daha önce gezdiğin konulara hızlıca erişebilirsin.
#include "stdio.h"
void hanoi(int,char,char,char);
void hanoi(int n,char frompeg,char topeg,char auxpeg)
{ if(n==1)
{ printf("\nMove disk 1 from peg %c to peg %c",frompeg,topeg);
return; }
hanoi(n-1,frompeg,auxpeg,topeg);
printf("\nMove disk %d from peg %c to peg %c",n,frompeg,topeg);
hanoi(n-1,auxpeg,topeg,frompeg);
}
main()
{ int n;
printf("<<< Please, enter the number of disks >>> : ");
scanf("%d",&n);
printf("The Tower of Hanoi involves the moves :\n\n");
hanoi(n,'A','C','B');
return 0;
getch();
}
DH forumlarında vakit geçirmekten keyif alıyor gibisin ancak giriş yapmadığını görüyoruz.
Üye Ol Şimdi DeğilÜye olduğunda özel mesaj gönderebilir, beğendiğin konuları favorilerine ekleyip takibe alabilir ve daha önce gezdiğin konulara hızlıca erişebilirsin.