锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
聽聽聽聽聽聽聽聽聽 鎴戠殑姹夎濉旂▼搴忛噰鐢ㄧ殑鏄掑綊璋冪敤鐨勬濇兂銆?br />聽 姹夎闂鐨勯掑綊鎬濇兂灝辨槸涓夋璧幫細
鍘熸潵閮藉湪A鏌憋紝杈呭姪B鏌憋紝鐩爣C鏌?/span>
錛?/span>1錛夋兂鍔炴硶鎶?/span>A鏌變笂鐨勯櫎鏈搴曚笅涓涓互澶栫殑鐩樺熷姪C鏌卞叏閮ㄧЩ鍒?/span> B鏌憋紝
錛?/span>2錛夋妸鏈鍚庡墿涓嬬殑涓涓洏浠?/span>A縐誨埌C錛?/span>
錛?/span>
3
錛夋妸
B
鏌變笂鐨勭洏鎯沖姙娉曞叏閮ㄧЩ鍒?/span>
C
鏌便?br />
聽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聽聽聽}
]]>