Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

CÓïÑÔº¯Êý£¨¶þ£©

¡¾Àý8.6¡¿HanoiËþÎÊÌâ
    Ò»¿é°åÉÏÓÐÈý¸ùÕ룬A£¬B£¬C¡£AÕëÉÏÌ×ÓÐ64¸ö´óС²»µÈµÄÔ²ÅÌ£¬´óµÄÔÚÏ£¬Ð¡µÄÔÚÉÏ¡£Èçͼ5.4Ëùʾ¡£Òª°ÑÕâ64¸öÔ²ÅÌ´ÓAÕëÒƶ¯CÕëÉÏ£¬Ã¿´ÎÖ»ÄÜÒƶ¯Ò»¸öÔ²ÅÌ£¬Òƶ¯¿ÉÒÔ½èÖúBÕë½øÐС£µ«ÔÚÈκÎʱºò£¬ÈκÎÕëÉϵÄÔ²Å̶¼±ØÐë±£³Ö´óÅÌÔÚÏ£¬Ð¡ÅÌÔÚÉÏ¡£ÇóÒƶ¯µÄ²½Öè¡£
±¾ÌâËã·¨·ÖÎöÈçÏ£¬ÉèAÉÏÓÐn¸öÅÌ×Ó¡£
Èç¹ûn=1£¬Ôò½«Ô²ÅÌ´ÓAÖ±½ÓÒƶ¯µ½C¡£
Èç¹ûn=2£¬Ôò£º
1.½«AÉϵÄn-1(µÈÓÚ1)¸öÔ²ÅÌÒƵ½BÉÏ£»
2.ÔÙ½«AÉϵÄÒ»¸öÔ²ÅÌÒƵ½CÉÏ£»
3.×îºó½«BÉϵÄn-1(µÈÓÚ1)¸öÔ²ÅÌÒƵ½CÉÏ¡£
Èç¹ûn=3£¬Ôò£º
A. ½«AÉϵÄn-1(µÈÓÚ2£¬ÁîÆäΪn`)¸öÔ²ÅÌÒƵ½B(½èÖúÓÚC)£¬²½ÖèÈçÏ£º
(1)½«AÉϵÄn`-1(µÈÓÚ1)¸öÔ²ÅÌÒƵ½CÉÏ¡£
(2)½«AÉϵÄÒ»¸öÔ²ÅÌÒƵ½B¡£
(3)½«CÉϵÄn`-1(µÈÓÚ1)¸öÔ²ÅÌÒƵ½B¡£
B. ½«AÉϵÄÒ»¸öÔ²ÅÌÒƵ½C¡£
C. ½«BÉϵÄn-1(µÈÓÚ2£¬ÁîÆäΪn`)¸öÔ²ÅÌÒƵ½C(½èÖúA)£¬²½ÖèÈçÏ£º
(1)½«BÉϵÄn`-1(µÈÓÚ1)¸öÔ²ÅÌÒƵ½A¡£
(2)½«BÉϵÄÒ»¸öÅÌ×ÓÒƵ½C¡£
(3)½«AÉϵÄn`-1(µÈÓÚ1)¸öÔ²ÅÌÒƵ½C¡£
   µ½´Ë£¬Íê³ÉÁËÈý¸öÔ²Å̵ÄÒƶ¯¹ý³Ì¡£
    ´ÓÉÏÃæ·ÖÎö¿ÉÒÔ¿´³ö£¬µ±n´óÓÚµÈÓÚ2ʱ£¬Òƶ¯µÄ¹ý³Ì¿É·Ö½âΪÈý¸ö²½Ö裺
µÚÒ»²½ °ÑAÉϵÄn-1¸öÔ²ÅÌÒƵ½BÉÏ£»
µÚ¶þ²½ °ÑAÉϵÄÒ»¸öÔ²ÅÌÒƵ½CÉÏ£»
µÚÈý²½ °ÑBÉϵÄn-1¸öÔ²ÅÌÒƵ½CÉÏ£»ÆäÖеÚÒ»²½ºÍµÚÈý²½ÊÇÀàͬµÄ¡£
µ±n=3ʱ£¬µÚÒ»²½ºÍµÚÈý²½ÓÖ·Ö½âΪÀàͬµÄÈý²½£¬¼´°Ñn`-1¸öÔ²ÅÌ´ÓÒ»¸öÕëÒƵ½ÁíÒ»¸öÕëÉÏ£¬ÕâÀïµÄn`=n-1¡£ ÏÔÈ»ÕâÊÇÒ»¸öµÝ¹é¹ý³Ì£¬¾Ý´ËËã·¨¿É±à³ÌÈçÏ£º
move(int n,int x,int y,int z)
{
    if(n==1)
      printf("%c-->%c\n",x,z);
    else
    {
      move(n-1,x,z,y);
      printf("%c-->%c\n",x,z);
      move(n-1,y,x,z);
    }
}
main()
{
    int h;
    printf("\ninput number:\n");
    scanf("%d",&h);
    printf("the step to moving %2d diskes:\n",h);
    move(h,'a','b','c');
}
    ´Ó³ÌÐòÖпÉÒÔ¿´³ö,moveº¯ÊýÊÇÒ»¸öµÝ¹éº¯Êý£¬ËüÓÐËĸöÐβÎn,x,y,z¡£n±íʾԲÅÌÊý£¬x,y,z·Ö±ð±íʾÈý¸ùÕë¡£move º¯ÊýµÄ¹¦ÄÜÊÇ°ÑxÉϵÄn¸öÔ²ÅÌÒƶ¯µ½zÉÏ¡£µ±n==1ʱ£¬Ö±½Ó°


Ïà¹ØÎĵµ£º

keil C ³öÏÖWARNING:MULTIPLE CALL TO SEGMENTµÄ½âÎö

µ÷ÊÔkeil³ÌÐòʱÓÐʱ»á³öÏÖ¸÷ÖÖ±àÒ뾯¸æ£¬Ò»°ãÇé¿öϲ»»áÓ°Ïì³ÌÐòµÄÔËÐС£µ«³öÏÖÈçÌâWARNING:MULTIPLE CALL TO SEGMENT¾¯¸æʱ£¬ÇëÁôÒâÄúµÄ³ÌÐòÊÇ·ñ»á·¢Éú´íÎó¡£ÉÏÊö¾¯¸æÖ¸µÄÊÇÄ㶨ÒåµÄº¯ÊýÌåÔÚÖ÷³ÌÐòÖб»µ÷Óã¬ÔÚÖжÏÖÐÒ²±»Ö±½Ó»ò¼ä½ÓµÄµ÷ÓÃÁË¡£¿ÉÏëÈôÖ÷³ÌÐòÕýÔËÐд˺¯Êýʱ£¬ÖжÏÀ´ÁÙÒ²ÔËÐÐÕâ¶Î³ÌÐòµÄ»°»á·¢Éúº¯ÊýÖØÔØÏÖÏó¡£ ......

C %m.ns Êä³ö

#include <stdio.h>
#define N 19
int main()
{
int i;
for (i=0;i<=N;i++)
{
printf("%*.*s%-*.*s\n",N,i<=N/2?i:N-1,"*******************",\
N,i<=N/2?i+1:N-i+1,"*******************");
}
return 0;
}

%m.ns ......

¸øÄãµÄC³ÌÐò¼ÓÉÏÑÕÉ«

±ê×¼C¿ØÖÆ̨³ÌÐòÒ²¿ÉÒÔ×Ô¶¨ÒåÎÄ×ÖÊä³öÑÕÉ«£¬ÈôòÓ¡ÐÅÏ¢¸üÏÊÃ÷£¬ÔÚdebugµÄʱºòÌرðÓÐÓ᣷½·¨ºÜ¼òµ¥£º
ת×Ô£ºhttp://www.diybl.com/course/3_program/c/c_js/20090303/157456.html
ÏÈ´ÓÒ»¸öÀý×Ó¿ªÊ¼
printf("\033[31m ####----->> \033[32m" "hello\n" "\033[m");

ÑÕÉ«·ÖΪ±³¾°É«ºÍ×ÖÌåÉ«£¬30~39ÓÃÀ´ÉèÖÃ×ÖÌåÉ« ......

CÕûÐÍÉý¼¶ºÍÑ°³£ËãÊõת»»

                                                   ......

CÓïÑÔÊý×é


ÔÚ³ÌÐòÉè¼ÆÖУ¬ÎªÁË´¦Àí·½±ã£¬°Ñ¾ßÓÐÏàͬÀàÐ͵ÄÈô¸É±äÁ¿°´ÓÐÐòµÄÐÎʽ×éÖ¯ÆðÀ´¡£ÕâЩ°´ÐòÅÅÁеÄͬÀàÊý¾ÝÔªËصļ¯ºÏ³ÆΪÊý×é¡£ÔÚ£ÃÓïÑÔÖУ¬Êý×éÊôÓÚ¹¹ÔìÊý¾ÝÀàÐÍ¡£Ò»¸öÊý×é¿ÉÒÔ·Ö½âΪ¶à¸öÊý×éÔªËØ£¬ÕâЩÊý×éÔªËØ¿ÉÒÔÊÇ»ù±¾Êý¾ÝÀàÐÍ»òÊǹ¹ÔìÀàÐÍ¡£Òò´Ë°´Êý×éÔªËصÄÀàÐͲ»Í¬£¬Êý×éÓÖ¿É·ÖΪÊýÖµÊý×é¡¢×Ö·ûÊý×é¡¢Ö¸ÕëÊý×é¡¢½á¹ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ