鏌便?br />聽1聽#include"stdio.h"
聽2聽void聽movedisk(int聽n,char聽fromneedle,char聽toneedle,char聽usingneedle);聽int聽i=0;
聽3聽main()
聽4聽{int聽m;
聽5聽聽int聽stop=1;
聽6聽聽printf("聽聽聽聽聽聽聽聽聽聽聽聽聽聽**********************************\n");
聽7聽聽printf("聽聽聽聽聽聽聽聽聽聽聽聽聽聽*聽聽聽Welcome聽to聽my聽program!!!^-^聽聽*\n");
聽8聽聽printf("聽聽聽聽聽聽聽聽聽聽聽聽聽聽**********************************\n");
聽9聽聽printf("This聽is聽a聽Game聽called聽Hanoi,you聽can聽follow聽the聽steps聽below聽to聽begin!!!\n");
10聽聽聽while(stop){i=0;
11聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽printf("Please聽input聽the聽number聽of聽the聽disk:");
12聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽scanf("%d",&m);
13聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽movedisk(m,'a','c','b');
14聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽printf("\nthe聽fewest聽steps聽you聽have聽to聽go聽is聽%d.\n",i);
15聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽printf("\nif聽you聽want聽to聽stop,input:0聽,else聽input:1\nInput:");
16聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽scanf("%d",&stop);
17聽聽聽聽聽聽聽聽聽聽聽聽聽聽}
18聽聽聽聽getch();
19聽聽}
20聽
21聽聽void聽movedisk(int聽n,char聽fromneedle,char聽toneedle,char聽usingneedle)
22聽{
23聽聽if(n==1)
24聽聽聽聽聽printf("[%d]聽聽%c--->%c\t",++i,fromneedle,toneedle);
25聽聽聽else聽if(n>1)
26聽聽聽聽聽聽{movedisk(n-1,fromneedle,usingneedle,toneedle);
27聽聽聽聽聽聽聽printf("[%d]聽聽%c--->%c\t",++i,fromneedle,toneedle);
28聽聽聽聽聽聽聽movedisk(n-1,usingneedle,toneedle,fromneedle);
29聽聽聽聽聽聽聽}
30聽
31聽聽聽}