Êý¾Ý½á¹¹Ï°Ìâ Ï°ÌâÒ» Ò»¡¢Ñ¡ÔñÌâ
1¡¢Êý¾Ý½á¹¹ÊÇÒ»ÃÅÑо¿·ÇÊýÖµ¼ÆËãµÄ³ÌÐòÉè¼ÆÎÊÌâÖеIJÙ×÷¶ÔÏóÒÔ¼°ËüÃÇÖ®¼äµÄ£¨B£©ºÍÔËËãµÄѧ¿Æ¡£
A£®½á¹¹ B£®¹Øϵ C£®ÔËËã D£®Ëã·¨ 2¡¢ÔÚÊý¾Ý½á¹¹ÖУ¬´ÓÂß¼ÉÏ¿ÉÒÔ°ÑÊý¾Ý½á¹¹·Ö³É£¨C£©¡£
A£®¶¯Ì¬½á¹¹ºÍ¾²Ì¬½á¹¹ B£®½ô´Õ½á¹¹ºÍ·Ç½ô´Õ½á¹¹ C£®ÏßÐԽṹºÍ·ÇÏßÐԽṹ D£®Âß¼½á¹¹ºÍ´æ´¢½á¹¹
3¡¢ÏßÐÔ±íµÄÂ߼˳ÐòºÍ´æ´¢Ë³Ðò×ÜÊÇÒ»Öµģ¬ÕâÖÖ˵·¨£¨B£©¡£
A£®ÕýÈ· B£®²»ÕýÈ· C£®ÎÞ·¨È·¶¨ D£®ÒÔÉϴ𰸶¼²»¶Ô
4¡¢Ëã·¨·ÖÎöµÄÄ¿µÄÊÇ£¨C£©¡£
A£®ÕÒ³öËã·¨µÄºÏÀíÐÔ B£®Ñо¿Ëã·¨µÄÊäÈËÓëÊä³ö¹Øϵ C£®·ÖÎöËã·¨µÄÓÐЧÐÔÒÔÇó¸Ä½ø D£®·ÖÎöËã·¨µÄÒ׶®ÐÔ ¶þ¡¢Ìî¿ÕÌâ
1¡¢Êý¾Ý ÊÇÐÅÏ¢µÄÔØÌ壬ÊǶԿ͹ÛÊÂÎïµÄ·ûºÅ±íʾ£¬ËüÄܹ»±»¼ÆËã»úʶ±ð¡¢´æ´¢¡¢¼Ó¹¤ºÍ´¦Àí£¬Êý¾Ý ÊǶÔÄܹ»ÓÐЧµÄÊäÈ˵½¼ÆËã»úÖв¢ÇÒÄܹ»±»¼ÆËã»ú´¦ÀíµÄ·ûºÅµÄ×ܳơ£ÀýÈ磬ÊýѧÖÐËùÓõ½µÄÕûÊýºÍʵÊý£¬Îı¾±à¼ËùÓõ½µÄ×Ö·û´®µÈ¡£
2¡¢Êý¾ÝÔªËØÊÇÊý¾ÝµÄ»ù±¾µ¥Î»£¬ÓÐЩÇé¿öÏÂÒ²³ÆΪԪËØ¡¢½áµã¡¢¶¥µã¡¢¼Ç¼µÈ¡£
3¡¢Êý¾ÝÏîÊÇÊý¾Ý²»¿É·Ö¸îµÄ×îСµ¥Ôª£¬ÊǾßÓжÀÁ¢º¬ÒåµÄ×îС±êʶµ¥Î»¡£ÀýÈç¹¹³ÉÒ»¸öÊý¾ÝÔªËصÄ×ֶΡ¢Óò¡¢ÊôÐԵȶ¼¿É³Æ֮Ϊ_Êý¾ÝÏî¡£
4¡¢¼ò¶øÑÔÖ®£¬Êý¾Ý½á¹¹ÊÇÊý¾ÝÖ®¼äµÄÏ໥¹Øϵ£¬¼´Êý¾ÝµÄ×éÖ¯ÐÎʽ¡£
5¡¢Êý¾ÝµÄÂß¼½á¹¹ÊÇÖ¸Êý¾ÝÖ®¼äµÄÂß¼¹Øϵ¡£Âß¼½á¹¹ÊÇ´ÓÂß¼¹ØϵÉÏÃèÊöÊý¾Ý£¬ËüÓë¾ßÌå´æ´¢Î޹أ¬ÊǶÀÁ¢ÓÚ¼ÆËã»úµÄ¡£Òò´ËÂß¼½á¹¹¿ÉÒÔ¿´×÷ÊÇ´Ó¾ßÌåÎÊÌâ³éÏó³öÀ´µÄÊýѧģÐÍ¡£
6¡¢Êý¾ÝµÄ´æ´¢½á¹¹Ö¸Êý¾ÝÔªËؼ°Æä¹ØϵÔÚ¼ÆËã»ú´æ´¢Æ÷Äڵıíʾ¡£´æ´¢½á¹¹ÊÇÂß¼½á¹¹ÔÚ¼ÆËã»úÀïµÄʵÏÖ£¬Ò²³Æ֮ΪӳÏñ¡£
7¡¢Êý¾ÝµÄÔËËãÊÇÖ¸¶ÔÊý¾ÝÊ©¼ÓµÄ²Ù×÷¡£Ëü¶¨ÒåÔÚÊý¾ÝµÄÂß¼½á¹¹Ö®ÉÏ£¬Ã¿ÖÖÂß¼½á¹¹¶¼ÓÐÒ»¸öÊý¾ÝµÄÔËËã¡£³£ÓõÄÓУº²éÕÒ¡¢ÅÅÐò¡¢²åÈË¡¢É¾³ý¡¢¸üеȲÙ×÷¡£
8¡¢Êý¾ÝÂß¼½á¹¹¿ÉÒÔ·ÖΪËÄÖÖ»ù±¾µÄÀàÐÍ£¬¼¯ºÏ½á¹¹ÖеÄÔªËسýÁ˽ö½öÖ»ÊÇͬÊôÓÚÒ»¸ö¼¯ºÏ_£¬²»´æÔÚʲô¹Øϵ¡£
9¡¢Êý¾ÝÂß¼½á¹¹µÄËÄÖÖ»ù±¾ÀàÐÍÖУ¬ÏßÐԽṹ_ÖеÄÔªËØÊÇÒ»ÖÖÒ»¶ÔÒ»µÄ¹Øϵ£¬ÕâÖֽṹµÄÌØÕ÷ÊÇ£ºÈô½á¹¹ÊÇ·Ç¿Õ¼¯£¬ÔòÓÐÇÒÖ»ÓÐÒ»¸ö¿ªÊ¼½áµãºÍÒ»¸öÖն˽áµã£¬²¢ÇÒËùÓнáµã×î¶àÖ»ÄÜÓÐÒ»¸öÖ±½ÓÇ°ÇýºÍÒ»¸öÖ±½Óºó¼Ì¡£
10¡¢Êý¾ÝÂß¼½á¹¹µÄËÄÖÖ»ù±¾ÀàÐÍÖУ¬Ê÷ÐνṹÖеÄÔªËØÊÇÒ»ÖÖÒ»¶Ô¶àµÄ¹Øϵ¡£
11¡¢Í¼Ðͽṹ»òͼ״½á¹¹ÊÇÒ»ÖÖ¶à¶Ô¶àµÄ¹Øϵ¡£ÔÚÕâÖÖÂß¼½á¹¹ÖУ¬ËùÓнáµã¾ù¿ÉÒÔÓжà¸öÇ°ÇýºÍ¶à¸öºó¼Ì¡£
12¡¢ÓÐʱҲ¿É½«Ê÷Ðͽṹ¡¢¼¯ºÏºÍͼÐͽṹ³ÆΪ·ÇÏßÐԽṹ£¬ÕâÑùÊý¾ÝµÄÂß¼½á¹¹¾Í¿ÉÒÔ·ÖΪÏßÐԽṹºÍ·ÇÏßÐԽṹÁ½´óÀà¡£ 13¡¢Ë³Ðò´æ´¢·½Ê½ÊÇÖ¸Âß¼ÉÏÏàÁڵĽáµã±»´æ´¢µ½ÎïÀíÉÏÒ²ÏàÁڵĴ洢µ¥ÔªÖС£ÕâÖÖ´æ´¢½á¹¹Ö»´æ´¢½áµãµÄÊýÖµ£¬²»´æ´¢½áµãÖ®¼äµÄ¹Øϵ£¬½áµãÖ®¼äµÄ¹ØϵÊÇͨ¹ý´æ´¢µ¥ÔªµÄÏàÁÚ¹ØϵÒþº¬µÄ±íʾ³öÀ´µÄ¡£
14¡¢Á´½Ó´æ´¢·½Ê½ÊÇÖÖ´æ´¢·½·¨£¬²»ÒªÇóÂß¼ÉÏÏàÁڵĽáµãÔÚÎïÀíÉÏÒ²ÏàÁÚ£¬¼´Êý¾ÝÔªËØ¿ÉÒÔ´æ´¢ÔÚÈÎÒâµÄλÖÃÉÏ¡£
15¡¢Ë÷Òý´æ´¢·½Ê½ÓÖ¿ÉÒÔ·ÖΪ³íÃÜË÷ÒýºÍÏ¡ÊèË÷Òý¡£Èôÿ¸ö½áµãÔÚË÷Òý±íÖж¼ÓÐÒ»¸öË÷ÒýÏÔò¸ÃÖÖË÷Òý´æ´¢·½Ê½³ÆΪ³íÃÜË÷Òý_£»ÈôÒ»×é½áµãÔÚË÷Òý±íÖÐÖ»¶ÔÓ¦Ò»¸öË÷ÒýÏÔòË÷Òý´æ´¢·½Ê½³ÆΪϡÊèË÷Òý¡£ÔÚ³íÃÜË÷ÒýÖУ¬Ë÷ÒýÏîµÄµØַָʾ½áµãËùÔÚµÄλÖ㬶øÏ¡ÊèË÷ÒýÖУ¬Ë÷ÒýÏîµÄµØַָʾһ×é½áµãµÄÆðʼλÖᣠ16¡¢É¢Áд洢·½Ê½ÊÇÀûÓýáµã¹Ø¼ü×ÖµÄÖµÖ±½Ó¼ÆËã³ö¸Ã½áµã´æ´¢µ¥ÔªµØÖ·£¬È»ºó½«½áµã°´Ä³ÖÖ·½Ê½´æÈ˸õØÖ·µÄÒ»ÖÖ·½·¨¡£
17¡¢ËùνËã·¨£¨Algorithm£©ÊǶÔÌض¨ÎÊÌâÇó½â·½·¨ºÍ²½ÖèµÄÒ»ÖÖÃèÊö£¬ËüÊÇÖ¸ÁîµÄÒ»×éÓÐÏÞÐòÁУ¬ÆäÖÐÿ¸öÖ¸Áî±íʾһ¸ö»ò¶à¸ö²Ù×÷¡£
18¡¢Ëã·¨µÄÓÐÇî_ÐÔÊÇÖ¸Ëã·¨±ØÐëÄܹ»ÔÚÖ´ÐÐÓÐÏÞ¸ö²½ÖèÖ®ºó½áÊø£¬²¢ÇÒÿ¸ö²½Ö趼±ØÐëÔÚÓÐÇîµÄʱ¼äÄÚÍê³É¡£
19¡¢Ëã·¨µÄÈ·¶¨ÐÔÊÇÖ¸Ëã·¨ÖеÄÿһ¸ö²½Öè±ØÐëÊÇÓÐÃ÷È·¶¨ÒåµÄ£¬²»ÔÊÐíÓÐÄ£ÀâÁ½¿ÉµÄ½âÊÍ£¬Ò²²»ÔÊÐíÓжàÒåÐÔ¡£²¢ÇÒ£¬ÔÚÈκÎÌõ¼þÏ£¬Ëã·¨Ö»ÄÜÓÐΩһµÄÒ»ÌõÖ´Ðз¾¶£¬¼´Ö»ÒªÊäÈËÊÇÏàͬµÄ¾ÍÖ»Äܵõ½ÏàͬµÄÊä³ö½á¹û¡£ 20¡¢Ëã·¨µÄ¿ÉÐÐÐÔÓÖ³ÆΪËã·¨µÄÄÜÐÐÐÔ£¬ÊÇÖ¸Ëã·¨ÖÐÃèÊöµÄ²Ù×÷ÊÇ¿ÉÒÔͨ¹ýÒѾʵÏֵĻù±¾ÔËËãÖ´ÐÐÓÐÏÞ_´ÎÀ´ÊµÏÖ£¬¼´Ëã·¨µÄ¾ßÌåʵÏÖÓ¦¸ÃÄܹ»±»¼ÆËã»úÖ´ÐС£
21¡¢ÅжÏÒ»¸öËã·¨µÄºÃ»µÖ÷ÒªÒÔϼ¸¸ö±ê×¼£ºÕýÈ·ÐÔ£¬¿É¶ÁÐÔ_¡¢½¡×³ÐÔ¡¢Ð§ÂÊ¡£ 22¡¢Ëã·¨·ÖÎöÊǶÔÒ»ÖÖËã·¨ËùÏûºÄµÄ¼ÆËã»ú×ÊÔ´µÄ¹ÀË㣬ÆäÖаüÀ¨¼ÆËã»úÔËÐÐʱ¼äµÄ³¤¶ÌºÍËùÕ¼¾Ý¿Õ¼äµÄ´óС¡£
23¡¢¿Õ¼ä¸´ÔӶȣ¨SPace ComPlexity£©Ò²ÊǶÈÁ¿Ò»¸öËã·¨ºÃ»µµÄ±ê×¼£¬ËüËùÃèÊöµÄÊÇËã·¨ÔÚÔËÐйý³ÌÖÐËùÕ¼Óô洢¿Õ¼äµÄ´óС¡£ Èý¡¢ÅжÏÌâ
1¡¢Ë³Ðò´æ´¢·½Ê½Ö»ÄÜÓÃÓÚ´æ´¢ÏßÐԽṹ¡££¨¡Á£©Ê÷ÐͽṹҲ¿ÉÒÔÓÃ˳Ðò·½Ê½½øÐд洢¡£
2¡¢Êý¾ÝÔªËØÊÇÊý¾ÝµÄ×îСµ¥Î»¡££¨¡Á£©Êý¾ÝÔªËØÊÇÊý¾ÝµÄ»ù±¾µ¥Î»£¬Êý¾ÝÏîÊÇÊý¾ÝµÄ×îСµ¥Î»¡£
3¡¢Ëã·¨¿ÉÒÔÓò»Í¬µÄÓïÑÔÃèÊö£¬Èç¹ûÓÃCÓïÑÔ»òPASCALÓïÑԵȸ߼¶ÓïÑÔÃèÊö£¬ÔòË㷨ʵ¼ÊÉϾÍÊdzÌÐòÁË¡££¨¡Á£©Ëã·¨Óø÷ÖÖ¼ÆËã»úÓïÑÔÃèÊö±íÏÖΪһ¸ö³ÌÐò£¬µ«ÊDz»µÈÓÚ³ÌÐò£¬³ÌÐòÂß¼²»Ò»¶¨ÄÜÂú×ãÓÐÇîÐÔ¡£
4¡¢Êý¾Ý½á¹¹ÊÇ´øÓнṹµÄÊý¾ÝÔªËصļ¯ºÏ¡££¨¶Ô£©
5¡¢Êý¾ÝµÄÂß¼½á¹¹ÊÇÖ¸¸÷ÔªËØÖ®¼äµÄÂß¼¹Øϵ£¬ÊÇÓû§¸ù¾ÝÐèÒª¶ø½¨Á¢µÄ¡££¨¶Ô£© 6¡¢Êý¾Ý½á¹¹¡¢Êý¾ÝÔªËØ¡¢Êý¾ÝÏîÔÚ¼ÆËã»úÖеÄÓ³Ïñ·Ö±ð³ÆΪ´æ´¢½á¹¹¡¢½áµã¡¢Êý¾ÝÓò¡££¨¶Ô£©
7¡¢Êý¾ÝµÄÎïÀí½á¹¹ÊÇÖ¸Êý¾ÝÔÚ¼ÆËã»úÖÐʵ¼ÊµÄ´æ´¢ÐÎʽ¡££¨¶Ô£©
8¡¢¾ßÓдæÈ¡ÈÎÒ»ÔªËصÄʱ¼äÏàµÈÕâÒ»ÌصãµÄ´æ´¢½á¹¹³ÆΪËæ»ú´æÈ¡½á¹¹¡££¨¶Ô£© ËÄ¡¢×ÛºÏÌâ
1¡¢ÓôóOÐÎʽ±íʾÏÂÃæËã·¨µÄʱ¼ä¸´ÔӶȣº for£¨i=0£»i£¼m£»iʮʮ£© for£¨j=0£»j£¼n£»j£«£«£©
A[i][j]=i*j£» O(m¡Án)¡£ 2¡¢Ð´³öÏÂÃæËã·¨µÄʱ¼ä¸´ÔӶȣº i£½0£»
s=0£»
while(s£¼n£© £û i++; s+=i;
£ý O(n)
3¡¢Ð´³öÒÔÏÂËã·¨µÄʱ¼ä¸´ÔӶȣº for£¨i£½0; i£¼m; i£«£«£©
for£¨j£½0 ; j£¼t; j£«£«£©
c[i][j]=0£»
for£¨i=0£»i£¼m£»i£«£«£©
for£¨j=o; j for£¨k=0£»k£¼n£»k£«£«£© c£Ûi£Ý£Ûj£Ý£«£½a£Ûi£Ý£Ûk£Ý*b[k][j]; 4¡¢Ð´³öÏÂÃæËã·¨µÄʱ¼ä¸´ÔӶȣº i=1; while£¨i£¼£½n£© i=i*3; log3(n)¡£ 5¡¢ÇóÏÂÃ溯ÊýÖи÷ÌõÓï¾äµÄƵ¶ÈºÍËã·¨µÄʱ¼ä¸´ÔӶȣº prime£¨int n£© £û int i£½2£» while ((n£¥i£©£¡=0£¦£¦i£¼sqrt(n) ) i++; if£¨i£¾sqrt(n) ) printf£¨¡±£¥d is a prime number.£Ün¡±£¬n£©£» else printf£¨¡±£¥d is not a prime number.£Ün¡±£¬n£©£»£ý O(m¡Án¡Át)¡£ O(n) Ï°Ìâ¶þ Ò»¡¢Ñ¡ÔñÌâ 1£®ÔÚÒ»¸ö³¤¶ÈΪnµÄ˳Ðò±íÖÐɾ³ýµÚi¸öÔªËØ£¨0£¼i A£®n-i B£®n-i+1 C£®n-i+1 D£®i+1 2£®´ÓÒ»¸ö¾ßÓÐn¸öÔªËصÄÏßÐÔ±íÖвéÕÒÆäÖµµÈÓÚxµÄ½áµãʱ£¬ÔÚ²éÕҳɹ¦µÄÇé¿öÏ£¬Ðèƽ¾ù±È½Ï(C )¸öÔªËؽáµã¡£ A£®n/2 B£®n C£®(n-1)/2 D£®(n +1)/2 3£®¶ÔÒ»¸ö¾ßÓÐn¸öÔªËصÄÏßÐÔ±í£¬½¨Á¢Æäµ¥Á´±íµÄʱ¼ä¸´ÔÓ¶ÈΪ( A)¡£ A£®O(n) B£®O(1) C£®O(n2£© D£®O£¨long2n£© 4£®ÏßÐÔ±í²ÉÓÃÁ´Ê½´æ´¢Ê±£¬ÆäµØÖ·( D )¡£ A£® ±ØÐëÊÇÁ¬ÐøµÄ B£®Ò»¶¨ÊDz»Á¬ÐøµÄ C£®²¿·ÖµØÖ·±ØÐëÁ¬Ðø D£®Á¬ÐøÓë·ñ¾ù¿ÉÒÔ 5£®ÔÚÒ»¸ö¾ßÓÐn¸ö½áµãµÄÓÐÐòµ¥Á´±íÖвåÈËÒ»¸öеĽáµã£¬Ê¹µÃÁ´±íÈÔÈ»ÓÐÐò£¬¸ÃËã·¨µÄʱ¼ä¸´ÔÓ¶ÈÊÇ(D )¡£ A£®O£¨long2n£© B£®O£¨l£© C£®O£¨n2£© D£®O£¨n£© 6£®ÏßÐÔ±íÊÇ(A )¡£ A£®Ò»¸öÓÐÏÞÐòÁУ¬¿ÉÒÔΪ¿Õ B£®Ò»¸öÓÐÏÞÐòÁУ¬²»¿ÉÒÔΪ¿Õ C£®Ò»¸öÎÞÏÞÐòÁУ¬¿ÉÒÔΪ¿Õ D£®Ò»¸öÎÞÏÞÐòÁУ¬²»¿ÉÒÔΪ¿Õ 7£®ÔÚÒ»¸ö³¤¶ÈΪnµÄ˳Ðò±íÖУ¬ÏòµÚi¸öÔªËØ£¨0Ò»1£¼n£«1£©Ö®Ç°²¶ÈËÒ»¸öÐÂÔªËØʱ£¬ÐèÒªÏòºóÒƶ¯( B )¸öÔªËØ¡£ A£®n-i B£®n-i£«1 C£®n£i£1 D£®i£«1 8£®Èç¹ûijÁ´±íÖÐ×î³£ÓõIJÙ×÷ÊÇÈ¡µÚi¸ö½áµã¼°ÆäÇ°Çý£¬Ôò²ÉÓÃ( D)´æ´¢·½Ê½×î½Úʡʱ¼ä¡£ A£®µ¥Á´±í B£®Ë«ÏòÁ´±í C£®µ¥Ñ»·Á´±í D£®Ë³Ðò±í 9£®Ò»¸ö˳Ðò´æ´¢ÏßÐÔ±íµÄµÚÒ»¸öÔªËصĴ洢µØÖ·ÊÇ90£¬Ã¿¸öÔªËصij¤¶ÈÊÇ2£¬ÔòµÚ6¸öÔªËصĴ洢µØÖ·ÊÇ£¨B£©¡£ A£®98 B£®100 C£®102 D£®106 10£®ÏÂÁÐÅÅÐò·½·¨ÖУ¬Ä³Ò»Ì˽áÊøºóδ±ØÄÜÑ¡³öÒ»¸öÔªËØ·ÅÔÚÆä×îÖÕλÖÃÉϵÄÊÇ( C)¡£ A£®¶ÑÅÅÐò B£®Ã°ÅÝÅÅÐò C£®Ö±½Ó²åÈËÅÅÐò D£®¿ìËÙÅÅÐò 11£®¶ÔÏßÐÔ±í½øÐжþ·Ö²éÕÒʱ£¬ÒªÇóÏßÐÔ±í±ØÐ루C£©¡£ A£®ÒÔ˳Ðò·½·¨´æ´¢ B£®ÒÔÁ´½Ó·½·¨´æ´¢ C£®ÒÔ˳Ðò·½·¨´æ´¢£¬ÇÒ½áµã½Ó¹Ø¼ü×ÖÓÐÐòÅÅÁÐ D£®ÒÔÁ´½Ó·½·¨´æ´¢£¬ÇÒ½áµã½Ó¹Ø¼ü×ÖÓÐÐòÅÅÁÐ 12£®ÔÚ˳Ðò´æ´¢µÄÏßÐÔ±í£¨a1??an£©ÖУ¬É¾³ýÈÎÒâÒ»¸ö½áµãËùÐèÒƶ¯½áµãµÄƽ¾ùÒƶ¯´ÎÊýΪ( C ) A£®n B£®n£¯2 C£®(n-1)/2 D£®£¨n£«l£©/2 13£®ÔÚÏßÐÔ±íµÄÏÂÁд洢½á¹¹ÖУ¬¶ÁÈ¡ÔªËØ»¨·ÑµÄʱ¼ä×îÉÙµÄÊÇ£¨D£©¡£ A£®µ¥Á´±í B£®Ë«Á´±í C£®Ñ»·Á´±í D£®Ë³Ðò±í 14£®ÈôijÁ´±íÖÐ×î³£ÓõIJÙ×÷ΪÔÚ×îºóÒ»¸ö½áµãÖ®ºó²åÈëÒ»¸ö½áµãºÍɾ³ý×îºóÒ»¸ö½áµã£¬Ôò²ÉÓã¨D£©´æ´¢·½Ê½×î½Úʡʱ¼ä¡£ A£®Ë«Á´±í B£®µ¥Á´±í C£®µ¥Ñ»·Á´±í D£®´øÍ·½áµãµÄË«Ñ»·Á´±í ¶þ¡¢Ìî¿ÕÌâ 1£®ÏßÐÔ±í£¨Linear List£©ÊÇ×î¼òµ¥¡¢×î³£ÓõÄÒ»ÖÖÊý¾Ý½á¹¹¡£ÏßÐÔ±íÖеÄÔªËØ´æÔÚ×Å___Ò»¶ÔÒ»µÄÏ໥¹Øϵ¡£ 2£®ÏßÐÔ±íÖÐÓÐÇÒ½öÓÐÒ»¸ö¿ªÊ¼½áµã£¬±íÖÐÓÐÇÒ½öÓÐÒ»¸öÖն˽áµã£¬³ý¿ªÊ¼½áµãÍ⣬ÆäËûÿ¸öÔªËØÓо޽öÓÐÒ»¸öÖ±½ÓÇ°Çý£¬³ýÖն˽áµãÍ⣬ÆäËûÿ¸öÔªËØÓÐÇÒ½öÓÐÒ»¸öÖ±½Óºó¼Ì 3£®ÏßÐÔ±íÊÇn£¨n>=0£©¸öÊý¾ÝÔªËصÄ_ÓÐÏÞÐòÁС£ÆäÖÐnΪÊý¾ÝÔªËصĸöÊý£¬¶¨ÒåΪÏßÐÔ±íµÄ³¤¶È¡£µ±nΪÁãʱµÄ±í³ÆΪ¿Õ±í¡£ 4£®Ëùν˳Ðò±í£¨Sequential LISt£©ÊÇÏßÐÔ±íµÄ˳Ðò´æ´¢½á¹¹£¬ËüÊǽ«ÏßÐÔ±íÖеĽáµã°´ÆäÂ߼˳ÐòÒÀ´Î´æ·ÅÔÚÄÚ´æÖÐÒ»×éÁ¬ÐøµÄ´æ´¢µ¥ÔªÖУ¬Ê¹ÏßÐÔ±íÖÐÏàÁڵĽáµã´æ·ÅÔÚµØÖ·ÏàÁڵĴ洢µ¥ÔªÖС£ 5£®µ¥Á´±í²»ÒªÇóÂß¼ÉÏÏàÁڵĴ洢µ¥ÔªÔÚÎïÀíÉÏÒ²Ò»¶¨ÒªÏàÁÚ¡£ËüÊÇ·ÖÅäһЩÈÎÒâµÄ´æ´¢µ¥ÔªÀ´´æ´¢ÏßÐÔ±íÖеÄÊý¾ÝÔªËØ£¬ÕâЩ´æ´¢µ¥Ôª¿ÉÒÔ·ÖÉ¢ÔÚÄÚ´æÖеÄÈÎÒâµÄλÖÃÉÏ£¬ËüÃÇÔÚÎïÀíÉÏ¿ÉÒÔÊÇһƬÁ¬ÐøµÄ´æ´¢µ¥Ôª£¬Ò²¿ÉÒÔÊDz»Á¬ÐøµÄ¡£Òò´ËÔÚ±íʾÏßÐÔ±íÕâÖÖÊý¾Ý½á¹¹Ê±£¬±ØÐëÔÚ´æ´¢ÏßÐÔ±íÔªËصÄͬʱ£¬Ò²´æ´¢ÏßÐÔ±íµÄÂß¼¹Øϵ¡£ 6£®ÏßÐÔ±íµÄÁ´Ê½´æ´¢½á¹¹µÄÿһ¸ö½áµã£¨Node£©ÐèÒª°üÀ¨Á½¸ö²¿·Ö£ºÒ»²¿·ÖÓÃÀ´´æ·ÅÔªËصÄÊý¾ÝÐÅÏ¢£¬³ÆΪ½áµãµÄÊý¾ÝÓò£»ÁíÒ»²¿·ÖÓÃÀ´´æ·ÅÔªËصÄÖ¸ÏòÖ±½Óºó¼ÌÔªËصÄÖ¸Õë(¼´Ö±½Óºó¼ÌÔªËصĵØÖ·ÐÅÏ¢)£¬³ÆΪָÕëÓò»òÁ´Óò¡£ 7£®ÏßÐÔÁ´±íµÄÂß¼¹ØϵÊÇͨ¹ýÿ¸ö½áµãÖ¸ÕëÓòÖеÄÖ¸ÕëÀ´±íʾµÄ¡£ÆäÂ߼˳ÐòºÍÎïÀí´æ´¢Ë³Ðò²»ÔÙÒ»Ö£¬¶øÊÇÒ»ÖÖ·Ç˳Ðò´æ´¢½á¹¹£¬ÓÖ³ÆΪ·Ç˳ÐòÓ³Ïñ¡£ 8£®Èç¹û½«µ¥Á´±í×îºóÒ»¸ö½áµãµÄÖ¸ÕëÓò¸ÄΪ´æ·ÅÁ´±íÖеÄÍ·½áµãµÄµØÖ·Öµ£¬ÕâÑù¾Í¹¹³ÉÁËÑ»·Á´±í ¡£ 9£®ÎªÁËÄܹ»¿ìËٵزéÕÒµ½ÏßÐÔ±íÔªËصÄÖ±½ÓÇ°Çý£¬¿ÉÔÚÿһ¸öÔªËصĽáµãÖÐÔÙÔö¼ÓÒ»¸öÖ¸ÏòÆäÇ°ÇýµÄÖ¸ÕëÓò£¬ÕâÑù¾Í¹¹³ÉÁËË«ÏòÁ´±í¡£ 10£®Ë«ÏòÁ´±íij½áµãµÄÖ¸ÕëP£¬ËüËùÖ¸Ïò½áµãµÄºó¼ÌµÄÇ°ÇýÓëÇ°ÇýµÄºó¼Ì¶¼ÊÇpËùÖ¸ÏòµÄ½áµã±¾Éí¡£ 11£®ÔÚµ¥Á´±íÖУ¬É¾³ýÖ¸ÕëPËùÖ¸½áµãµÄºó¼Ì½áµãµÄÓï¾äÊÇP->next=p->next->next _¡£ 12£®ÔÚË«Ñ»·Á´±íÖУ¬É¾³ýÖ¸ÕëPËùÖ¸½áµãµÄÓï¾äÐòÁÐÊÇP->prior->next£½p->next¼°P->next->prior=P->prior _¡£ 13£®µ¥Á´±íÊÇÏßÐÔ±íµÄÁ´½Ó´æ´¢±íʾ¡£ 14£®¿ÉÒÔʹÓÃË«Á´±í±íʾÊ÷Ðνṹ¡£ 15£®ÏòÒ»¸ö³¤¶ÈΪnµÄÏòÁ¿µÄµÚi¸öÔªËØ(l¡Üi¡Ün+1£©Ö®Ç°²åÈËÒ»¸öÔªËØʱ£¬ÐèÏòºóÒƶ¯n-i+1¸öÔªËØ¡£ 16£®É¾³ýÒ»¸ö³¤¶ÈΪnµÄÏòÁ¿µÄµÚi¸öÔªËØ£¨l¡Üi¡Ün£©Ê±£¬ÐèÏòÇ°Òƶ¯n-i ¸öÔªËØ¡£ 17£®ÔÚµ¥Á´±íÖУ¬ÔÚÖ¸ÕëPËùÖ¸½áµãµÄºóÃæ²åÈËÒ»¸ö½áµãSµÄÓï¾äÐòÁÐÊÇS->next=P->next; P->next=S 18£®ÔÚË«Ñ»·Á´±íÖУ¬ÔÚÖ¸ÕëPËùÖ¸½áµãÇ°²åÈËÖ¸ÕëSËùÖ¸µÄ½áµã£¬ÐèÖ´ÐÐÓï¾äp->prior->next=S; s->prior=p->prior; s->next=p; p->prior=s; 19£®È¡³ö¹ãÒå±íA£½£¨£¨x£¬£¨a£¬b£¬c£¬d£©£©ÖÐÔ×ÓcµÄº¯ÊýÊÇhead(tail(tail((head(tail(head(A))))))¡£ 20£®ÔÚÒ»¸ö¾ßÓÐn¸ö½áµãµÄÓÐÐòµ¥Á´±íÖвåÈËÒ»¸öнáµã²¢Ê¹Ö®ÈÔÈ»ÓÐÐòµÄʱ¼ä¸´ÔÓ¶ÈΪO(n)¡£ 21£®Ð´³ö´øÍ·½áµãµÄË«ÏòÑ»·Á´±íLΪ¿Õ±íµÄÌõ¼þ(L==L->Next) && (L==L->Prior) ¡£ 22£®ÏßÐÔ±í¡¢Õ»ºÍ¶ÓÁж¼ÊÇÏßÐÔ_½á¹¹¡£ 23£®ÏòÕ»ÖвåÈËÔªËصIJÙ×÷ÊÇÏÈÒƶ¯Õ»¶¥Õ룬ÔÙ´æÈËÔªËØ¡£ Èý¡¢ÅжÏÌâ 1£®ÏßÐÔ±í²ÉÓÃÁ´±í´æ´¢Ê±£¬½áµãºÍ½áµãÄÚ²¿µÄ´æ´¢¿Õ¼ä¿ÉÒÔÊDz»Á¬ÐøµÄ¡££¨´í£© 2£®ÔÚ¾ßÓÐÍ·½áµãµÄÁ´Ê½´æ´¢½á¹¹ÖУ¬Í·Ö¸ÕëÖ¸ÏòÁ´±íÖеĵÚÒ»¸öÊý¾Ý½áµã¡£(´í) 3£®Ë³Ðò´æ´¢µÄÏßÐÔ±í²»¿ÉÒÔËæ»ú´æÈ¡¡££¨´í£© 4£®µ¥Á´±í²»ÊÇÒ»ÖÖËæ»ú´æ´¢½á¹¹¡££¨¶Ô£© 5£®Ë³Ðò´æ´¢½á¹¹ÏßÐÔ±íµÄ²åÈëºÍɾ³ýÔËËãËùÒƶ¯ÔªËصĸöÊýÓë¸ÃÔªËصÄλÖÃÎ޹ء£(´í) 6£®Ë³Ðò´æ´¢½á¹¹ÊǶ¯Ì¬´æ´¢½á¹¹£¬Á´Ê½´æ´¢½á¹¹ÊǾ²Ì¬´æ´¢½á¹¹¡££¨´í£© 7£®ÏßÐÔ±íµÄ³¤¶ÈÊÇÏßÐÔ±íËùÕ¼ÓõĴ洢¿Õ¼äµÄ´óС¡££¨´í£© 8£®Ë«Ñ»·Á´±íÖУ¬ÈÎÒâÒ»½áµãµÄºó¼ÌÖ¸Õë¾ùÖ¸ÏòÆäÂß¼ºó¼Ì¡££¨´í£© 9£®ÏßÐÔ±íµÄΩһ´æ´¢ÐÎʽÊÇÁ´±í¡££¨´í£© ËÄ¡¢×ÛºÏÌâ 1£®±àдһ¸ö½«´øÍ·½áµãµ¥Á´±íÄæÖõÄËã·¨¡£ void reverse_list( linklist * head ) { /*ÄæÖôøÍ·½áµãµÄµ¥Á´±í*/ linklist *s, *p; p=head->next; /*pÖ¸ÏòÏßÐÔ±íµÄµÚÒ»¸öÔªËØ*/ head->next=NULL; /*³õʼ¿Õ±í*/ while ( p != NULL ) { s=p; p=p->next; s->next=head->next; head->next=s; /*½«s½áµã²åÈëÄæ±í*/ } } /*reverse_list*/ 2£®haºÍhb·Ö±ðÊÇÁ½¸ö°´ÉýÐòÅÅÁеġ¢´øÍ·½áµãµÄµ¥Á´±íµÄÍ·Ö¸Õ룬Éè¼ÆÒ»¸öËã·¨£¬°ÑÕâÁ½¸öµ¥Á´±íºÏ²¢³ÉÒ»¸ö°´ÉýÐòÅÅÁеĵ¥Á´±í£¬²¢ÓÃhCÖ¸ÏòËüµÄÍ·½áµã¡£ linklist *combine_list( linklist *ha, linklist *hb ) { /*ha, hb·Ö±ðÊÇÁ½¸ö°´ÉýÐòÅÅÁеÄ,´øÓÐÍ·½áµãµÄµ¥Á´±íµÄÍ·Ö¸Õ룬Éè¼ÆÒ»¸öËã·¨£¬°ÑÕâÁ½¸öµ¥Á´±íºÏ²¢³ÉÒ»¸ö°´ÉýÐòÅÅÁеĵ¥Á´±í,²¢ÓÃhcÖ¸ÏòËüµÄÍ·½áµã*/ linklist *hc, *pa, *pb, *pc, *p, *q, *r; hc=(linklist *)malloc(sizeof(linklist)); /*½¨Á¢hcÍ·½áµã*/ p=hc; pa=ha->next; free(ha); /*ÊÍ·ÅhaÍ·½áµã*/ pb=hb->next; free(hb); /*ÊÍ·ÅhbÍ·½áµã*/ while (pa!=NULL && pb!=NULL ) { q=(linklist *)malloc (sizeof (linklist)); /*²úÉúнáµã*/ if (pb->data pb=pb->next; free(r); } } p->next=q; /*½«½áµãÁ´ÈëcÁ´±í*/ p=q; } while(pa!=NULL) /*aÁ´±í·Ç¿Õ*/ { q=(linklist *)malloc (sizeof (linklist)); q->data=pa->data; pa=pa->next; p->next=q; p=q; } while(pb!=NULL) /*bÁ´±í·Ç¿Õ*/ { q=(linklist *)malloc (sizeof (linklist)); q->data=pb->data; pb=pb->next; p->next=q; p=q; } p->next=NULL; return(hc); /*·µ»Ø*/ } 3£®ÓÐÒ»¸ö´øÍ·½áµãµÄµ¥Á´±í£¬Í·Ö¸ÕëΪhead£¬±àдһ¸öËã·¨count£®list£¨£©¼ÆËãËùÓÐÊý¾ÝÓòΪXµÄ½áµãµÄ¸öÊý£¨²»°üÀ¨Í·½áµã£©¡£ int count_list(linklist *head ) { /*ÔÚ´øÍ·½áµãµÄµ¥Á´±íÖмÆËãËùÓÐÊý¾ÝÓòΪxµÄ½áµãµÄ¸öÊý*/ linklist *p; int n; p=head->next; /*pÖ¸ÏòÁ´±íµÄµÚÒ»¸ö½áµã*/ n=0; while (p!=NULL) { if (p->data==x) n++; p=p->next; } return(n); /*·µ»Ø½áµã¸öÊý*/ } /*count_list*/ head£¬ËüµÄÊý¾ÝÓòµÄÀàÐÍΪÕûÐÍ£¬ ¶øÇÒ°´ÓÉСµ½´óµÄ˳ÐòÅÅÁУ¬±àдһ¸öËã·¨insertx£ßlist£¨£©£¬ÔÚ¸ÃÁ´±íÖÐ 4£®ÔÚÒ»¸ö´øÍ·½áµãµÄµ¥Á´±íÖУ¬Í·Ö¸ÕëΪ linklist *insertx_list(linklist *head, int x) { /*ÔÚ´øÍ·½áµãµÄµ¥Á´±íÖвåÈëֵΪxµÄÔªËØ£¬Ê¹¸ÃÁ´±íÈÔÈ»ÓÐÐò*/ linklist *s, *p, *q; s=(linklist *)malloc(sizeof(linklist)); /*½¨Á¢Êý¾ÝÓòΪxµÄ½áµã*/ s->data=x; s->next=NULL; if (head->next==NULL || x ²åÈËֵΪxµÄÔªËØ£¬²¢Ê¹¸ÃÁ´±íÈÔÈ»ÓÐÐò head->next=s; } else { q=head->next; p=q->next; while( p != NULL && x>p->data ) { q=p; p=p->next; } s->next=p; q->next=s; } /*if*/ } /**insertx_list*/ ¡£ 5£®ÔÚÒ»¸ö´øÍ·½áµãµÄµ¥Á´±íÖУ¬headΪÆäÍ·Ö¸Õ룬pÖ¸ÏòÁ´±íÖеÄijһ¸ö½áµã£¬±àдËã·¨swapin£®list£¨£©£¬ÊµÏÖpËùÖ¸ÏòµÄ½áµãºÍpµÄºó¼Ì½áµãÏ໥½»»»¡£ linklist *swapin_list(linklist *head, linklist *p) { /*ÔÚ´øÍ·½áµãµÄµ¥Á´±íÖУ¬ÊµÏÖpËùÖ¸ÏòµÄ½áµãºÍpµÄºó¼Ì½áµãÏ໥½»»»*/ linklist *q, *r, *s; q=p->next; /*qΪpµÄºó¼Ì*/ if (q !=NULL) /*ÈôpÓкó¼Ì½áµã*/ { if (p==head) /*ÈôpÖ¸ÏòÍ·½áµã*/ { head=head->next; s=head->next; head->next=p; p->next=s; } else /*p²»Ö¸ÏòÍ·½áµã*/ { r=head; /*¶¨Î»pËùÖ¸Ïò½áµãµÄÇ°Çý*/ while (r->next != p) r=r->next; r->next=q; /*½»»»pºÍqËùÖ¸ÏòµÄ½áµã*/ p->next=q->next; q->next=p; } return(head); } else /*p²»´æÔÚºó¼Ì*/ return(NULL); }/*swapin_list*/ ÓÐÒ»¸ö´øÍ·½áµãµÄµ¥Á´±í£¬ËùÓÐÔªËØÖµÒԷǵݼõÓÐÐòÅÅÁУ¬headΪÆäÍ·Ö¸Õ룬±àдËã·¨deldy£®list£¨£©½«linklist *deldy_list(linklist *head) { /*ÔÚ´øÍ·½áµãµÄ·ÇµÝ¼õÓÐÐòµ¥Á´±í£¬½«¸ÃÁ´±íÖжàÓàµÄÔªËØÖµÏàͬµÄ½áµãɾ³ý*/ linklist *q; if (head->next!= NULL)/*ÅжÏÁ´±íÊÇ·ñΪ¿Õ*/ { p=head->next; while (p->next != NULL ) 6£® { if ( p->data != p->next->data ) p=p->next; else { q=p->next;/*qÖ¸ÏòpµÄºó¼Ì*/ p->next=q->next; /*ɾ³ýqËùÖ¸ÏòµÄ½áµã*/ free(q); /*ÊͷŽáµã¿Õ¼ä*/ } } /*while*/ } /*if*/ return(head); } /*deldy_list*/ ¸ÃÁ´±íÖжàÓàÔªËØÖµÏàͬµÄ½áµãɾ³ý¡£ 7£®ÔÚ´øÍ·½áµãµÄµ¥Á´±íÖУ¬Éè¼ÆËã·¨dellistmaxmin£¬É¾³ýËùÓÐÊý¾ÝÓò´óÓÚmin£¬¶øСÓÚmaxµÄÔªËØ¡£ linklist *dellist_maxmin(linklist *head, int min, int max ) { linklist *p, *q; q=head; p=head->next; while(p!=NULL) /*½áµã²»¿Õ*/ if ((p->data<=min) || (p->data>=max)) /*²»Âú×ãɾ³ýÌõ¼þ*/ { q=p; p=p->next; } else /*Âú×ãɾ³ýÌõ¼þ*/ { q->next=p->next; free(p); q=q->next; } } /*dellist_maxmin*/ 8£®Éè¼ÆÒ»¸ö½«Ë«Á´±íÄæÖõÄËã·¨invert£®dblinklist£¨£©£¬ÆäÖÐÍ·Ö¸ÕëΪhead£¬½áµãÊý¾ÝÓòΪdata£¬Á½¸öÖ¸ÕëÓò·Ö±ðΪpriorºÍnext¡£ ½«Ë«Á´±íÄæÖõÄËã·¨invert_dblinklistµÄËã·¨ÈçÏÂËùʾ£º void invert_dblinklist( *head ) { /*½«headÖ¸ÏòµÄË«Á´±íÄæÖÃ*/ dblinklist *p, *q; p=head; do { q=p->next; p->next=p->prior; p->prior=q; p=q; }while( p!=head ) } /*invert_dblinklist*/ linklist Ï°ÌâÈý Ò»¡¢Ñ¡ÔñÌâ l£®Ò»¸öÕ»µÄÐòÁÐÊÇ£ºa£¬b£¬c£¬d£¬e£¬ÔòÕ»µÄ²»¿ÉÄÜÊä³öµÄÐòÁÐÊÇ£¨C£©¡£ A£®a£¬b£¬c£¬d£¬e B£®d£¬e£¬c£¬b£¬a C£®d£¬c£¬e£¬a£¬b D£®e£¬d£¬c£¬b£¬a 2£®ÈôÒ»¸öÕ»µÄÊäÈËÐòÁÐÊÇ1£¬2£¬3£¬?£¬n£¬Êä³öÐòÁеĵÚÒ»¸öÔªËØÊÇn£¬ÔòµÚk¸öÊä³öÔªËØÊÇ£¨ C£©¡£ A£®k B£®n-k-1 C£®n-k+1 D£®²»È·¶¨ 3£®Åж¨Ò»¸öÕ»S£¨×î¶àÓÐn¸öÔªËØ£©Îª¿ÕµÄÌõ¼þÊÇ£¨ B £©¡£ A£®S->top£¡£½0 B£®S->top= =0 C£®S->top!=n D£®S->top= =n 4£®Åж¨Ò»¸öÕ»S£¨×î¶àÓÐn¸öÔªËØ£©ÎªÂúµÄÌõ¼þÊÇ£¨D £©¡£ A£®S->top!=0 B£®S->top= =0 C£®S->top!=n D£®S->top= =n 5£®ÏòÒ»¸öÕ»¶¥Ö¸ÕëΪtopµÄÁ´Õ»ÖвåÈËÒ»¸ö*S½áµãµÄʱºò£¬Ó¦µ±Ö´ÐÐÓï¾ä£¨ B £©¡£ A£®top->next=S£» B£®S->next=top£»top=S£» C£®S->next£½top->next£»top->next£½S£»D£®S->next£½top£»top£½S->next£» 6£®ÏòÒ»¸ö´øÍ·½áµã¡¢Õ»¶¥Ö¸ÕëΪtopµÄÁ´Õ»ÖвåÈËÒ»¸ö*S½áµãµÄʱºò£¬Ó¦µ±Ö´ÐÐÓï¾ä£¨ C £©¡£ A£®top->next=S£» B£®S->next=top£»top=S£» C£®S->next=top->next£»top->next=S£» D£®S->next=top£»top=S->next£» 7£®Åж¨Ò»¸ö¶ÓÁÐQ£¨×î¶àÓÐn¸öÔªËØ£©Îª¿ÕµÄÌõ¼þÊÇ£¨ C £©¡£ A£®Q->rear-Q->front= =n B£®Q->rear-Q->front+1= =n C£®Q->rear = = Q->front D£®Q->rear +1= = Q->front 8£®Åж¨Ò»¸ö¶ÓÁÐQ£¨×î¶àÓÐn¸öÔªËØ£©ÎªÂúµÄÌõ¼þÊÇ£¨A£©¡£ A£®Q->rear-Q->front= =n B£®Q->rear-Q->front+1= =n C£®Q->rear = = Q->front D£®Q->rear +1= = Q->front 9£®Åж¨Ò»¸öÑ»·¶ÓÁÐQ£¨×î¶àÓÐn¸öÔªËØ£©Îª¿ÕµÄÌõ¼þÊÇ£¨ A £©¡£ A£®Q->rear = = Q->front B£®Q->rear = = Q->front£«l C£®Q->front= =(Q->rear +1)£¥n D£®Q->front= =(Q->rear -1)£¥n 10£®Åж¨Ò»¸öÑ»·¶ÓÁÐQ£¨×î¶àÓÐn¸öÔªËØ£©ÎªÂúµÄÌõ¼þÊÇ£¨ C £©¡£ A£®Q->rear = = Q->front B£®Q->rear = = Q->front£«l C£®Q->front= =(Q->rear +1)£¥n D£®Q->front= =(Q->rear -1)£¥n 11£®ÔÚÒ»¸öÁ´¶ÓÁÐÖУ¬¼Ù¶¨frontºÍrear·Ö±ðΪͷָÕëºÍβָÕ룬Ôò²åÈëÒ»¸ö½áµã*SµÄ²Ù×÷ÊÇ£¨ C £©¡£ A£®front£½front->next B£®S->next=rear£»rear=S C£®rear->next=S£»rear=S D£®S->next=front£»front£½S 12£®ÔÚÒ»¸öÁ´¶ÓÁÐÖУ¬¼Ù¶¨frontºÍrear·Ö±ðΪͷָÕëºÍβָÕ룬ɾ³ýÒ»¸ö½áµãµÄ²Ù×÷ÊÇ£¨ A £©¡£ A£®front=front->next B£®rear=rear->next C£®rear->next=front D£®front->next£½rear 13£®Õ»Óë¶ÓÁж¼ÊÇ£¨ C £©¡£ A£®Á´Ê½´æ´¢µÄÏßÐԽṹ B£®Á´Ê½´æ´¢µÄ·ÇÏßÐԽṹ C£®ÏÞÖÆ´æÈ¡µãµÄÏßÐԽṹ D£®ÏÞÖÆ´æÈ¡µãµÄ·ÇÏßÐԽṹ 14£®Èô½øÕ»ÐòÁÐΪl£¬2£¬3£¬4£¬Ôò£¨ C £©²»¿ÉÄÜÊÇÒ»¸ö³öÕ»ÐòÁС£ A£®3£¬2£¬4£¬1 B£®l£¬2£¬3£¬4 C£®4£¬2£¬3£¬1 D£®4£¬3£¬2£¬l 15£®ÔÚ½â¾ö¼ÆËã»úÖ÷»úÓë´òÓ¡»úÖ®¼äËٶȲ»Æ¥ÅäÎÊÌâʱͨ³£ÉèÖÃÒ»¸ö´òÓ¡Êý¾Ý»º³å Çø£¬Ö÷»ú½«ÒªÊä³öµÄÊý¾ÝÒÀ´ÎдÈ˸ûº³åÇø£¬¶ø´òÓ¡»úÔò´Ó¸Ã»º³åÇøÖÐÈ¡×ßÊý¾Ý´òÓ¡¡£¸Ã»º³åÇøÓ¦¸ÃÊÇÒ»¸ö£¨ B £©½á¹¹¡£ A£®¶ÑÕ» B£®¶ÓÁÐ C£®Êý×é D£®ÏßÐÔ±í ¶þ¡¢Ìî¿Õ»Ø 1£®Õ»£¨stack£©ÊÇÏÞ¶¨ÔÚ±íβһ¶Ë½øÐвåÈË»òɾ³ý²Ù×÷µÄÏßÐÔ±í¡£ÔÚÕ»ÖУ¬ÔÊÐí²åÈ˺Íɾ³ý²Ù×÷µÄÒ»¶Ë³ÆΪջ¶¥£¬¶øÁíÒ»¶Ë³ÆΪջµ×¡£²»º¬ÔªËصÄÕ»³ÆΪ¿ÕÕ» ¡£ 2£®ÔÚÕ»µÄÔËËãÖУ¬Õ»µÄ²åÈ˲Ù×÷³ÆΪ½øÕ»»òÈëÕ»µÄɾ³ý²Ù×÷³ÆΪÍËÕ»»ò³öÕ»¡£ 3£®¸ù¾ÝÕ»µÄ¶¨Ò壬ÿһ´Î½øÕ»µÄÔªËض¼ÔÚÔÕ»¶¥ÔªËØÖ®ÉÏ£¬²¢³ÉΪеÄÕ»¶¥ÔªËØ£»Ã¿Ò»´Î³öÕ»µÄÔªËØ×ÜÊǵ±Ç°µÄÕ»¶¥ÔªËØ£¬Òò´Ë×îºó½øÕ»µÄÔªËØ×ÜÊÇ×îÏȳöÕ»£¬ËùÒÔÕ»Ò²³ÆΪºó½øÏȳöÏßÐÔ±í£¬¼ò³ÆΪLIFO±í¡£ 4£®Õ»ÊÇÒ»ÖÖ²Ù×÷Êܵ½ÏÞÖƵÄÏßÐÔ±í£¬ÊÇÒ»ÖÖÌØÊâµÄÏßÐÔ±í£¬Òò´ËÕ»Ò²ÓÐ˳ÐòºÍÁ´Ê½_Á½ÖÖ´æ´¢½á¹¹£¬·Ö±ð³ÆΪ¡¢Ë³ÐòÕ»_ºÍ_Á´Õ»¡£ 5£®µ±Õ»ÂúµÄʱºò£¬ÔÙ½øÐÐÈËÕ»²Ù×÷¾Í»á²úÉúÒç³ö£¬ÕâÖÖÇé¿öµÄÒç³ö³ÆΪÉÏÒç__£»µ±Õ»¿ÕµÄʱºò£¬Èç¹ûÔÙ½øÐгöÕ»²Ù×÷£¬Ò²»áÒç³ö£¬ÕâÖÖÇé¿öϵÄÒç³ö³ÆΪÏÂÒç¡£ 6£®Õ»µÄÁ´Ê½´æ´¢½á¹¹¼ò³ÆΪÁ´Õ»£¬ÊÇÒ»ÖÖ_ÌØÊâµÄµ¥Á´±í¡£ 7£®ÈËÃÇÈÕ³£¼ÆËãÓõ½µÄ±í´ïʽ¶¼±»³ÆΪÖÐ׺±í´ïʽ£¬ÕâÊÇÓÉÓÚÕâÖÖËãÊõ±í´ïʽµÄÔËËã·û±»ÖÃÓÚÁ½¸ö²Ù×÷ÊýÖм䡣 8£®¼ÆËã»úÖÐͨ³£Ê¹Óúó׺±í´ïʽ£¬ÕâÊÇÒ»ÖÖ½«ÔËËã·ûÖÃÓÚÁ½¸ö²Ù×÷ÊýºóÃæµÄËãÊõ±í´ïʽ¡£ÕâÖÖ±í´ïʽÊÇÓɲ¨À¼¿Æѧ¼ÒлάÆæÌá³öµÄ£¬Òò´ËÓÖ³ÆΪ²¨À¼Ê½¡£ 9£®¶ÓÁУ¨Queue£©Ò²ÊÇÒ»ÖÖÌØÊâµÄÏßÐÔ±í_£¬µ«ËüÓëÕ»²»Í¬£¬¶ÓÁÐÖÐËùÓеIJåÈ˾ùÏÞ¶¨ÔÚ±íµÄÒ»¶Ë½øÐУ¬¶øËùÓеÄɾ³ýÔòÏÞ¶¨ÔÚ±íµÄÁíÒ»¶Ë½øÐС£ÔÊÐí²åÈ˵ÄÒ»¶Ë³ÆΪ¶Ó⣬ÔÊÐíɾ³ýµÄÒ»¶Ë³ÆΪ¶ÓÍ·¡£ 10£®¶ÓÁеÄÌصãÊÇÏȽøÏȳö£¬Òò´Ë¶ÓÁÐÓÖ±»³ÆΪÏȽøÏȳö£®µÄÏßÐÔ±í£¬»ò³ÆΪFIFO±í¡£ 11£®¶ÓÁеÄ˳Ðò´æ´¢½á¹¹ÓÖ³ÆΪ˳Ðò¶ÓÁУ¬ÊÇÓÃÒ»×éµØÖ·Á¬ÐøµÄ´æ´¢µ¥ÔªÒÀ´Î´æ·Å¶ÓÁÐÖеÄÔªËØ¡£ 12£®ÓÉÓÚ¶ÓÁÐÖеÄÔªËؾ³£±ä»¯£¬¶ÔÓÚ¶ÓÁеÄɾ³ýºÍ²åÈË·Ö±ðÔÚ¶ÓÍ·ºÍ¶Óβ½øÐУ¬Òò´ËÐèÒªÉèÖÃÁ½¸öÖ¸Õë·Ö±ðÖ¸Ïò¶ÓÍ·ÔªËغͶÓβԪËØ£¬ÕâÁ½¸öÖ¸ÕëÓÖ³ÆΪ¶ÓÍ·Ö¸ÕëºÍ¶ÓβָÕë ¡£ 13£®Ñ»·Ë³Ðò¶ÓÁУ¨Circular Sequence Queue£©¾³£¼ò³ÆΪѻ·¶ÓÁУ¬ËüÊǽ«´æ´¢Ë³Ðò¶ÓÁеĴ洢ÇøÓò¿´³ÉÊÇÒ»¸öÊ×βÏàÁ¬µÄÒ»¸ö»·£¬¼´½«¶ÓÊ׺ͶÓβԪËØÁ¬½ÓÆðÀ´ÐγÉÒ»¸ö»·ÐÎ±í¡£Ê×βÏàÁ¬µÄ״̬ÊÇͨ¹ýÊýѧÉϵġ¢È¡Ä£ÔËËãÀ´ÊµÏֵġ£ 14£®ÔÚËã·¨»ò³ÌÐòÖУ¬µ±Ò»¸öº¯ÊýÖ±½Óµ÷ÓÃ×Ô¼º»òͨ¹ýһϵÁÐÓï¾ä¼ä½Óµ÷ÓÃ×Ô¼ºµÄʱºò£¬Ôò³ÆÕâ¸öº¯ÊýΪµÝ¹éº¯Êý£¬Ò²³ÆΪ×Ôµ÷Óú¯Êý¡£º¯ÊýÖ±½Óµ÷ÓÃ×Ô¼º£¬Ôò³ÆΪֱ½ÓµÝ¹éµ÷Ó㻵±Ò»¸öº¯Êýͨ¹ýÁíÒ»¸öº¯ÊýÀ´µ÷ÓÃ×Ô¼ºÔò³ÆΪ¼ä½ÓµÝ¹éµ÷Óᣠ15£®ÔÚÑ»·¶ÓÁÐÖй涨£ºµ±Q->rear= =Q->frontµÄʱºòÑ»·¶ÓÁÐΪ¿Õ_£¬ µ±£¨Q->rear+1£©£¥MAXSIZE£½frontµÄʱºòÑ»·¶ÓÁÐΪÂú¡£ 16£®ÓÃÁ´±í·½Ê½±íʾµÄ¶ÓÁгÆΪÁ´¶ÓÁС£ 17£®ÒÑÖªÕ»µÄÊäÈËÐòÁÐΪ1£¬2£¬3£¬?£¬n£¬Êä³öÐòÁÐΪa1£¬a2£¬?£¬an£¬·ûºÏa2= =nµÄÊä³öÐòÁй²ÓÐn-1¡£ 18£®Ò»¸öÕ»µÄÊäÈËÐòÁÐÊÇ12345£¬ÔòÕ»µÄÊä³öÐòÁÐΪ43512ÊDz»¿ÉÄÜµÄ £¨ÌîÊÇ·ñ¿ÉÄÜ£©¡£ 19£®Ò»¸öÕ»µÄÊäÈËÐòÁÐÊÇ12345£¬ÔòÕ»µÄÊä³öÐòÁÐΪ12345ÊÇ¿ÉÄܵģ¨ÌîÊÇ·ñ¿ÉÄÜ£©¡£ 20£®Éèsq[1£®£®maxsize]Ϊһ¸ö˳Ðò´æ´¢µÄÕ»£¬±äÁ¿topָʾջ¶¥ÔªËصÄλÖã¬Ôò×÷ÈëÕ» ²Ù×÷µÄÌõ¼þÊÇtop!=maxsize¡£ 21£®Éèsq[1£®£®maxsize]Ϊһ¸ö˳Ðò´æ´¢µÄÕ»£¬±äÁ¿topָʾջ¶¥ÔªËصÄλÖã¬Èç¹û°ÑÕ»¶¥ÔªËص¯³ö²¢Ë͵½XÖУ¬ÔòÐèÖ´ÐÐÓï¾äx=sq[top]; top=top-1¡£ 22£®Õ»µÄÌØÐÔÊÇÏȽøºó³ö¡£ 23£®¶ÔÕ»½øÐÐÍËջʱµÄ²Ù×÷ÊÇÏÈÈ¡³öÔªËØ£¬ºóÒƶ¯Õ»¶¥Ö¸Õë¡£ 24£®Éès[1£®£®max]Ϊһ¸ö˳Ðò´æ´¢µÄÕ»£¬±äÁ¿topָʾջ¶¥Î»Öã¬Õ»ÎªÂúµÄÌõ¼þÊÇtop==max¡£ 25£®ÉèÁ´Õ»µÄÕ»¶¥Ö¸ÕëΪtop£¬ÔòÕ»·Ç¿ÕµÄÌõ¼þÊÇtop!=nil ¡£ 26£®ÒÑ֪ѻ·¶ÓÁÐÓÃÊý×édata[1...n]´æ´¢ÔªËØÖµ£¬ÓÃf£¬r·Ö±ð×÷ΪͷβָÕ룬 Ôòµ±Ç°ÔªËظöÊýΪ(n+r-f)mod n¡£ 27£®ÔÚÒ»¸öÑ»·¶ÓÁÐÖУ¬¶ÓÊ×Ö¸ÕëÖ¸Ïò¶ÓÊ×ÔªËصÄÇ°Ò»¸öλÖᣣ¨Ç°Ò»¸ö»òºóÒ»¸ö£© 28£®¶ÓÁÐÖÐÔÊÐí½øÐÐɾ³ýµÄÒ»¶Ë³ÆΪ¶ÓÊס£ 29£®Á´¶ÓÁÐʵ¼ÊÉÏÊÇÒ»¸öͬʱ´øÓÐÍ·Ö¸ÕëºÍβָÕëµÄµ¥Á´±í£¨1£®£®n£©£¬Î²Ö¸ÕëÖ¸Ïò¸Ãµ¥Á´±íµÄµÚn¸öÔªËØ¡£ 30£®ÉèË«ÏòÁ´±íÁ´ÁÐΪlq£¬lqµÄÍ·Ö¸ÕëΪlq.Front£¬Î²Ö¸ÕëΪlq.Rear£¬Ôò¶ÓÁÐΪ¿ÕµÄÌõ¼þÊÇlq->front==lq->rear¡£ 31£®´ÓÑ»·¶ÓÁÐÖÐɾ³ýÒ»¸öÔªËØ£¬Æä²Ù×÷ÊÇÏÈÈ¡³öÒ»¸öÔªËØ£¬ºóÒƶ¯Õ»¶¥Ö¸Õë¡£ 32£®¶ÓÁÐÖÐÔÊÐí½øÐвåÈëµÄÒ»¶Ë³ÆΪ¶Óβ¡£ Èý¡¢ÅжÏÌâ 1£®Õ»ºÍ¶ÓÁж¼ÊÇÏÞÖÆ´æÈ¡µãµÄÏßÐԽṹ¡£¶Ô £© 2£®²»Í¬µÄÈËÕ»ºÍ³öÕ»×éºÏ¿ÉÄܵõ½ÏàͬÊä³öÐòÁС£´íÎ󣺲»Í¬µÄÈëÕ»ºÍ³öÕ»×éºÏµÃµ½²»Í¬Êä³öÐòÁС£ £© 3£®Ïû³ýµÝ¹éÒ»¶¨ÒªÓÃÕ»¡££¨´íÎó£ºÄ³Ð©Çé¿öÈçβµÝ¹é¿ÉÒÔת»»ÎªµÝÍƵÄÐÎʽ¡£ £© 4£®Ñ»·¶ÓÁÐÊÇ˳Ðò´æ´¢½á¹¹¡££¨ÕýÈ·£© 5£®Ñ»·¶ÓÁв»»á²úÉúÒç³ö¡££¨´íÎó£ºÑ»·¶ÓÁв»»á²úÉú¼ÙÒç³ö £© 6£®Ñ»·¶ÓÁÐÂúµÄʱºòrear= =front¡££¨ ´íÎó £© 7£®ÔÚ¶ÔÁ´¶ÓÁУ¨´øÍ·½áµã£©×ö³ö¶Ó²Ù×÷ʱ²»»á¸Ä±äfrontÖ¸ÕëµÄÖµ¡££¨ÕýÈ·£© ËÄ¡¢×ÛºÏÌâ 1£®ÉèÓÐ4¸öÔªËØA¡¢B¡¢CºÍD½øÕ»£¬¸ø³öËüÃÇËùÓпÉÄܵijöÕ»ÖÈÐò¡£ A¡¢B¡¢C¡¢D A¡¢B¡¢D¡¢C A¡¢C¡¢B¡¢D A¡¢C¡¢D¡¢B A¡¢D¡¢C¡¢B B¡¢A¡¢C¡¢D B¡¢A¡¢D¡¢C B¡¢C¡¢A¡¢D B¡¢C¡¢D¡¢A B¡¢D¡¢C¡¢A C¡¢B¡¢A¡¢D C¡¢B¡¢D¡¢A C¡¢D¡¢B¡¢A D¡¢C¡¢B¡¢A 2£®ÊäÈën¸ö10ÒÔÄÚµÄÊý£¬Ã¿ÊäÈëk£¨0£¼=k£¼=9£©£¬¾Í°ÑËü²åÈ˵½µÚkºÅ¶ÓÁÐÖС£×îºó°Ñ10¸ö¶ÓÁÐÖеķǿնÓÁа´¶ÓÁÐÐòºÅÒÔ´ÓСµ½´óµÄ˳Ðò´®½Ó³ÉÒ»ÌõÁ´£¬²¢Êä³ö¸ÃÁ´ÖеÄËùÓÐÔªËØ¡£ #include int data; struct node *next; }; struct hnode { struct node *link; } queue[MAX]; main() { int A[N],n,i,first=1; struct node *p,*s,*head; printf(\ÊýÖµ¸öÊýn:\ scanf(\ for (i=0;i for (i=0;i for(i=0;i { s=(struct node *)malloc (sizeof (struct node)); /*½¨Á¢½áµã*/ s->data=A[i]; s->next=NULL; if (queue[A[i]].link==NULL) /*ÊÇÏàÓ¦¶ÓÁеĵÚÒ»¸ö½áµã*/ queue[A[i]].link=s; else /*²»ÊÇÏàÓ¦¶ÓÁеĵÚÒ»¸ö½áµã*/ { p=queue[A[i]].link; while (p->next!=NULL) p=p->next; /*pÖ¸Ïò¸ÃÁ´±íµÄ×îºóÒ»¸ö½áµã*/ p->next=s; } } head=(struct node *)malloc (sizeof (struct node)); /*½¨Á¢ÐµÄ×ÜÁ´±íÍ·½áµã*/ head->next=NULL; for (i=0;i if (first) /*ÊÇÁ´Èë×ÜÁ´±íµÄµÚÒ»¸öÁ´±í*/ { head->next = queue[i].link; first=0; p=head; while (p->next!=NULL) p=p->next; /*pÖ¸Ïò×îºó½áµã*/ } else /*²»ÊÇÁ´Èë×ÜÁ´±íµÄµÚÒ»¸öÁ´±í*/ { p->next=queue[i].link; p=queue[i].link; while (p->next!=NULL) p=p->next; } } } printf(\ÏÔʾËùÓÐÔªËØ:\\n\ if (head->next!=NULL) /*pÖ¸Ïò×ÜÁ´±íµÄÊ×½áµã*/ p=head->next; while (p!=NULL) { printf(\ p=p->next; } } 3£®¼ÙÉèÓÃÑ»·µ¥Á´±íʵÏÖÑ»·¶ÓÁУ¬¸Ã¶ÓÁÐֻʹÓÃÒ»¸öβָÕërear£¬ÆäÏàÓ¦µÄ´æ´¢½á¹¹ºÍ»ù±¾²Ù×÷Ëã·¨ÈçÏ£º (l) ³õʼ»¯¶ÓÁÐ initqueue (Q)£º½¨Á¢Ò»¸öеĿնÓÁÐ Q¡£ (2) È˶ÓÁÐenqueue (Q£¬x)£º½«ÔªËØ x²åÈ˵½¶ÓÁÐ QÖС£ (3) ³ö¶ÓÁÐdelqueue (Q)£º´Ó¶ÓÁÐQÖÐÍ˳öÒ»¸öÔªËØ¡£ (4) È¡¶ÓÊ×ÔªËØgethead (Q)£º·µ»Øµ±Ç°¶ÓÊ×ÔªËØ¡£ (5) Åж϶ÓÁÐÊÇ·ñΪ¿Õ£ºemptyqueue (Q)¡£ (6) ÏÔʾ¶ÓÁÐÖÐÔªËØ£ºdispqueue (Q)¡£ /*Ö»ÓÐÒ»¸öÖ¸ÕërearµÄÁ´Ê½¶ÓµÄ»ù±¾²Ù×÷*/ #include typedef char elemtype; struct node /*¶¨ÒåÁ´¶ÓÁнáµã*/ { elemtype data; struct node *next; }; typedef struct queue /*¶¨ÒåÁ´¶ÓÁÐÊý¾ÝÀàÐÍ*/ { struct node *rear; } LinkQueue; void initqueue(LinkQueue *Q)/*³õʼ»¯¶ÓÁÐ*/ { Q=(struct queue *)malloc(sizeof(struct queue)); Q->rear=NULL; } void enqueue(LinkQueue *Q,elemtype x) /*Èë¶ÓËã·¨*/ { struct node *s,*p; s=(struct node *)malloc(sizeof(struct node)); s->data=x; if (Q->rear==NULL) /*ÔΪ¿Õ¶Óʱ*/ { Q->rear=s; s->next=s; } else /*Ô¶Ó²»Îª¿Õʱ*/ { p=Q->rear->next; /*pÖ¸ÏòµÚÒ»¸ö½áµã*/ Q->rear->next=s; /*½«sÁ´½Óµ½¶Óβ*/ Q->rear=s; /*Q->rearÖ¸Ïò¶Óβ*/ s->next=p; } } void delqueue(LinkQueue *Q) /*³ö¶ÓËã·¨*/ { struct node *t; if (Q->rear==NULL) { printf(\¶ÓÁÐΪ¿Õ!\\n\ return(0); } else if (Q->rear->next==Q->rear) /*Ö»ÓÐÒ»¸ö½áµãʱ*/ { t=Q->rear; Q->rear=NULL; } else /*Óжà¸ö½áµãʱ*/ { t=Q->rear->next; /*tÖ¸ÏòµÚÒ»¸ö½áµã*/ Q->rear->next=t->next; /*Òý³ÉÑ»·Á´*/ } free(t); } elemtype gethead(LinkQueue *Q) /*È¡¶ÓÊ×ÔªËØËã·¨*/ { if (Q->rear==NULL) printf(\¶ÓÁÐΪ¿Õ!\\n\ else return(Q->rear->next->data); } int emptyqueue(LinkQueue *Q) /*Åж϶ÓÁÐÊÇ·ñΪ¿ÕËã·¨*/ { if (Q->rear==NULL) return(1); /*Ϊ¿Õ,Ôò·µ»Øtrue*/ else return(0); /*²»Îª¿Õ,Ôò·µ»Øflase*/ } void dispqueue(LinkQueue *Q) /*ÏÔʾ¶ÓÁÐÖÐÔªËØËã·¨*/ { struct node *p=Q->rear->next; printf(\¶ÓÁÐÔªËØ:\ while (p!=Q->rear) { printf(\ p=p->next; } printf(\} 4£®¡°»ØÎÄ¡±ÊÇÖ¸Ò»¸ö×Ö·û´®´ÓÍ·¶Áµ½Î²ºÍ´Óβ¶Áµ½Í·¶¼Ò»Ñù¡£¼ÙÉè×Ö·û´®ÊÇ´ÓÊäÈËÉ豸һ´ÎÒ»¸ö×ֽڵĶÁÈË£¬²¢ÇÒ¶Áµ½×Ö·û¡°££¡±µÄʱºò±íʾ½áÊø¡£ÇëÓÃÕ»ºÍ¶ÓÁбàдһ¸öËã·¨ÅÐ ¶ÏÒ»¸ö×Ö·û´®ÊÇ·ñ»ØÎÄ¡£ int isPalindrome( ) { /*»ØÎÄÅж¨Ëã·¨*/ InitStack(S); InitQueue(Q); While((c=read())!='#') { push(S,c); /*¶ÁÈë×Ö·û·Ö±ð±£´æÔÚÕ»ºÍ¶ÓÁÐÖÐ*/ EnQueue(Q,c); } While( !QmptyStack( S ) && ! EmptyQueue( Q ) ) { if (pop(S) != DelQueue(Q)) /*ÕýÐòºÍÄæÐò×Ö·ûµÄ±È½Ï*/ return (FALSE); } if ( !EmptyStack(S) || ! EmptyQueue( Q ) return (FALSE); return( TRUE ); } /*isPalindrome*/ 5£®¼ÙÉè±í´ïʽÖÐÓÐÈýÖÖÀ¨ºÅ£ºÔ²À¨ºÅ¡°£¨£©¡±¡¢·½À¨ºÅ¡°[ ]¡±ºÍ»¨À¨ºÅ¡°{ }¡±ÓÃCÓïÑÔ±àд³ÌÐòÅж϶ÁÈ˵ıí´ïʽÖв»Í¬À¨ºÅÊÇ·ñÕýÈ·Åä¶Ô£¬¼Ù¶¨¶ÁÈ˵ıí´ïʽÒÔ¡±#¡±½áÊø¡£ #include \#include \#define FALSE 0 #define TRUE 1 #define LEN sizeof( struct node ) struct node { char data; struct node *next; }; typedef struct node *stack; void push_stack(stack *, char ); int pop_stack(stack *); void main() { stack s; int valid=TRUE; char ch,symble; symble=getchar(); s=NULL; push_stack(&s, '#'); while ((symble != '#' ) && (valid ==TRUE) ) { if ( symble !='(' && symble !=')' && symble != '[' && symble != ']' && symble !='{' && symble != '}' ) { symble=getchar(); } else if (symble=='(' || symble=='[' || symble=='{' ) { push_stack(&s, symble ); symble=getchar(); } else if ( s==NULL ) { valid=FALSE; } else { ch=pop_stack(&s); if ( (ch=='(' && symble==')') || (ch=='[' && symble==']') || ch==('{' && symble=='}') ) { valid=TRUE; symble=getchar(); } else valid=FALSE; } } if ( valid == TRUE ) printf(\ else printf(\} void push_stack( stack *topptr, char ch ) { stack newptr; newptr=(struct node * ) malloc( LEN ); newptr->data=ch; newptr->next=*topptr; *topptr=newptr; } int pop_stack( stack topptr ) { stack tempptr; char popvalue; if (topptr!=NULL ) { tempptr=topptr; popvalue=topptr->data; topptr=topptr->next; free( tempptr ); return popvalue; } else return 0; } 6£®ÓÃCÓïÑÔ±àд±³°üÎÊÌâµÄËã·¨¡£±³°üÎÊÌâµÄÃèÊöÊÇ£º¼ÙÉèÓÐn¼þÖÊÁ¿·Ö±ðΪw1£¬w2£¬?£¬wnµÄÎïÆ·ºÍÒ»¸ö×î¶àÄÜ×°ÔØ×ÜÖÊÁ¿ÊÇTµÄ±³°ü£¬ÎÊÄÜ·ñ´ÓÕân¼þÎïÆ·ÖÐÑ¡ÔñÈô¸É¼þÎïÆ·×°È˱³°ü£¬²¢ÇÒʹ±»Ñ¡ÎïÆ·µÄ×ÜÖÊÁ¿Ç¡ºÃµÈÓÚ±³°üËùÄÜ×°ÔصÄ×î´óÖÊÁ¿£¬¼´Wxl£«Wx2£«?Wxk£½T¡£ÈôÄÜ£¬Ôò±³°üÎÊÌâÓн⣬·ñÔò±³°üÎÊÌâÎ޽⡣ #include \ #define NUMBER 20 /*¶¨ÒåÎïÆ·¸öÊý*/ #define TRUE 1 #define FALSE 0 int stack[NUMBER]; int top; void main() { int knapproblem( int, int, int[]); int weight[NUMBER]; /*´æ·ÅÎïÆ·ÖÊÁ¿µÄÊý×é*/ int n, i; int maxweight; /*°üËùÄܳÐÊܵÄ×î´óÖØÁ¿*/ printf(\ scanf(\ printf(\ scanf(\ printf( \ Please input every object's weight :\\n\ for (i=1; i<=n; i++ ) scanf(\if (knapproblem(n, maxweight, weight ) == TRUE ) /*µ÷Óñ³°ü´¦Àíº¯Êý*/ { printf(\ printf(\ for ( ;top>0;top-- ) printf(\stack[top],weight[stack[top]]); /*pop stack and print every weight*/ printf(\ } else printf(\} /*main*/ int knapproblem( int n, int maxweight, int weight[] ) /*±³°üÎÊÌâ´¦Àíº¯Êý*/ { /*func kanpstack*/ int i=1; top=0; while ((maxweight>0)&&(i<=n)) { if ((maxweight-weight[i]==0) || ((maxweight-weight[i] >0 )&& (i /*Push No.i stack*/ stack[ ++top ]=i; maxweight = maxweight-weight[i]; } if ( maxweight==0) /*Äܹ»×°Èë°üÖÐ*/ { return( TRUE ); } else if (( i==n )&& (top>0)) /*¼ÌÐøÊÔ̽*/ { i=stack[top]; top=top-1; maxweight = maxweight+weight[i]; } i++; } /*while*/ return( FALSE ); } /*knapproblem*/ 7£®»®·Ö×Ó¼¯ÎÊÌâµÄÇó½â¡£»®·Ö×Ó¼¯ÎÊÌâµÄʵ¼ÊÀý×Ӻܶ࣬È磺ij¸öÔ˶¯»áÉèÁ¢n¸ö±ÈÈüÏîÄ¿£¬Ã¿¸öÔ˶¯Ô±¿ÉÒԲμÓÒ»µ½Èý¸öÏîÄ¿£¬¿¼Âǵ½Í¬Ò»Ô˶¯Ô±²Î¼ÓµÄÏîÄ¿²»Äܹ»ÔÚͬһʱ¼äÄÚ½øÐУ¬ÔòÈçºÎ°²ÅűÈÈüÈճ̲ÅÄÜʹ×ܵÄÈÕ³Ì×î¶Ì¡£ÓÖÈ磺ѧУ¿ªÉèm¿Æ¿Î³Ì£¬²»Í¬µÄͬѧ¿ÉÄÜÑ¡ÐÞ¶àÃŲ»Í¬µÄ¿Î³Ì£¬ÔÚѧÆÚÄ©Òª½øÐп¼ÊÔ£¬ÔòÈçºÎ°²ÅÅÕâm¿Æ¿Î³ÌµÄ¿¼ÊÔ²ÅÄÜʹ¿¼ÊÔʱ¼ä×î¶Ì¶øÓÖ²»³åÍ»¡£ #include \ #define MAX 10 /*ÔªËØÊýÄ¿*/ int r[MAX][MAX]; /*´æ·Å¹Øϵ¾ØÕó*/ int n; int result[MAX]; /*´æ·Å·Ö×é½á¹û*/ void main() { void division( int [MAX][MAX] ); /*ÉùÃ÷»®·Ö×Ó¼¯º¯Êý*/ int i, j; printf(\ scanf(\ printf(\matrix,1 rash, 0 no rash:\\n\/*ÊäÈë³åÍ»¾ØÕó,1³åÍ»,0²»³åÍ»*/ for ( i=1; i<=n; i++ ) for( j=1; j<=n; j++ ) scanf(\ division(r); /*µ÷ÓÃ×Ó¼¯»®·Öº¯Êý*/ for( i=1; i<=n; i++ ) /*Êä³ö·Ö×é½á¹û*/ printf(\i, result[i]); } void division ( int r[MAX][MAX]) { /*×Ó¼¯»®·Öº¯Êý*/ int newr[MAX]; /*¼Ç¼ËùÓÐÒÔÈë×éµÄÔªËØ·¢Éú³åÍ»µÄÔªËØÐÅÏ¢*/ int cq[MAX]; /*Ñ»·¶ÓÁÐ*/ int i, k; int front, rear; /*Ñ»·¶ÓÁÐͷβָÕë*/ int group, pre; for (k=0; k<=n-1; k++ ) /*n¸öÔªËØÒÀ´ËÈë¶ÓÁÐ*/ cq[k]=k+1; for ( k=0; k<=n; k++)/*³õʼ״̬,¾ù²»³åÍ»*/ newr[k]=0; group=1; pre=0; while (( rear != front ) || (rear != 0 )) { front=(front+1)%n; i=cq[front]; if (i else /*¿ÉÒÔ·ÖÔÚµ±Ç°×é*/ { result[i]=group; for (k=1; k<=n; k++ ) newr[k]=newr[k]+r[i][k]; /*²¹³ä²úÉú³åÍ»µÄÔªËØ*/ } pre=i; } } /*division*/ 8£®Ð´³öººÅµËþÎÊÌâµÄµÝ¹éºÍ·ÇµÝ¹éËã·¨¡£ ººÅµËþÎÊÌâÃèÊöΪ£ºÓÐX¡¢YºÍZÈý¸öÖù×Ó£¬n¸ö´óС²»µÈÇÒ¶¼ÄÜÌ×½øÖù×ÓµÄÔ²ÅÌ£¨±àºÅΪl¡¢2¡¢?¡¢n£©£¬Õân¸öÔ²ÅÌÒѾ°´ÕÕ×ÔÉÏÖÁÏ¡¢ÓÉСµ½´óµÄ˳ÐòÔÚÆäÖеÄÒ»¸ùÖù×ÓXÉÏ£¬ÒªÇó½«ÕâЩԲÅÌ°´ÕÕÈçϹæÔòÓÉXÖù×ÓÒƶ¯µ½ZÖù×Ó£º (1) ÿ´ÎÖ»ÄÜÒƶ¯Öù×Ó×îÉÏÃæµÄÒ»¸öÔ²ÅÌ¡£ (2) ÈκÎÔ²Å̶¼²»ÄÜ·ÅÔÚ±ÈËüСµÄÔ²ÅÌÖ®ÉÏ¡£ (3) Ô²ÅÌÖ»ÄÜÔÚX¡¢YºÍZÈý¸ùÖù×ÓÖ®ÉÏ·ÅÖᣠ/*ººÅµËþÎÊÌâµÄµÝ¹éËã·¨*/ void move( from, to ) char from, to; { /*ººÅµËþÒƶ¯¹ý³Ì*/ printf(\Êä³öÒƶ¯¹ý³Ì*/ }/*move*/ void hanoi( n,x,y,z ) /*µÝ¹éÖ´Ðйý³Ì*/ char x,y,z; int n; { if ( n==1 ) move( x,z ); else { hanoi( n-1,x,z,y ); move( x,z ); hanoi( n-1,y,x,z ); } }/*hanoi*/ main() { int n; printf(\input the nmmber of diskes:\\n\ scanf(\ printf(\ hanoi( n,'A','B','C' ); } /*ººÅµËþÎÊÌâµÄ·ÇµÝ¹éËã·¨*/ #include \struct node { char x; char y; char z; int id; }stack[30]; main() { int i=1; int n; char s; printf(\ scanf(\ printf(\ if( n==1 ) printf(\ else { stack[1].id=n; stack[1].x='A'; stack[1].y='B'; stack[1].z='C'; do { while( n>1 ) { n--; i++; stack[i].id=n; stack[i].x=stack[i-1].x; stack[i].y=stack[i-1].z; stack[i].z=stack[i-1].y; } printf(\ printf(\ printf(\ printf(\ printf(\ i--; do { if( i>=1 ) { printf(\ printf(\ printf(\ printf(\ printf(\ } stack[i].id = stack[i].id-1; n=stack[i].id; if( n>=1 ) { s=stack[i].x; stack[i].x = stack[i].y; stack[i].y=s; } if( n==1 ) { printf(\ printf(\ printf(\ printf(\stack[i].z); i--; } }while( (n<=1)&&(i>0) ) }while( i>0 ) } getch(); } Ï°ÌâËÄ Ò»¡¢Ñ¡ÔñÏî l£®¿Õ´®Óë¿Õ¸ñ´®£¨ B £©¡£ A£®Ïàͬ B£®²»Ïàͬ C£®¿ÉÄÜÏàͬ D£®ÎÞ·¨È·¶¨ 2£®ÉèÓÐÁ½¸öÉêS1ÓëS2£¬Çó´®S2ÔÚS1ÖÐÊ״γöÏÖλÖõÄÔËËã³Æ×÷£¨ C £©¡£ A£®Á¬½Ó B£®Çó×Ó´® C£®Ä£Ê½Æ¥Åä D£®ÅÐ×Ó´® 3£®´®ÓëÆÕͨµÄÏßÐÔ±íÏà±È½Ï£¬ËüµÄÌØÊâÐÔÌåÏÖÔÚ£¨ C £©¡£ A£®Ë³ÐòµÄ´æ´¢½á¹¹ B£®Á´½ÓµÄ´æ´¢½á¹¹ C£®Êý¾ÝÔªËØÊÇÒ»¸ö×Ö·û D£®Êý¾ÝÔªËØ¿ÉÒÔÈÎÒâ 4£®ÉèÓд®S=¡®Computer¡¯£¬ÔòÆä×Ó´®µÄÊýÄ¿ÊÇ£¨ A £©¡£ A£®36 B£®37 C£®8 D£®9 ¶þ¡¢¾³¿ÕÌâ 1£®´®ÊÇÓÉÁã¸ö»ò¶à¸ö×Ö·û×é³ÉµÄÓÐÏÞÐòÁС£Í¨³£¼Ç×÷£ºs£½¡°c1£¬c2£¬?£¬cn¡±(n=>0)£¬ÆäÖУ¬S³ÆΪ´®Ãû£»´®ÖеÄCi£¨1<=i<=n£©¿ÉÒÔÊÇ×Öĸ¡¢Êý×Ö ×Ö¸ñ»òÆäËû×Ö·û¡£ÓÃË«ÒýºÅÀ¨ÆðÀ´µÄ²¿·ÖÊÇ´®Öµ£®¼´´®SµÄÄÚÈÝ¡£ 2£®´®ÖÐ×Ö·ûµÄ¸öÊý³ÆΪ´®µÄ³¤¶È¡£ 3£®²»º¬ÓÐÈκÎ×Ö·ûµÄ´®³ÆΪ¿Õ´®£¬ËüµÄ³¤¶ÈΪÁã¡£ 4£®ÓÉÒ»¸ö»ò¶à¸ö¿Õ¸ñ¹¹³ÉµÄ´®³ÆΪ¿Õ¸ñ´®£¬ËüµÄ³¤¶ÈΪ¿Õ¸ñµÄ¸öÊý¡£ 5£®´®ÖÐÈÎÒâ¶à¸öÁ¬Ðø×Ö·û×é³ÉµÄ×ÓÐòÁгÆΪ¸Ã´®µÄ×Ó´®£»°üº¬×Ó´®µÄ´®³ÆΪÖ÷´®¡£ 6£®×Ö·ûÔÚÐòÁÐÖеÄÐòºÅ³ÆΪ¸Ã×Ö·ûÔÚ´®ÖеÄλÖᣠ7£®Á½¸ö×Ö·û´®ÏàµÈÊÇÖ¸Á½¸ö×Ö·û´®µÄ£¬Ò²¾ÍÊÇ˵ÕâÁ½¸ö×Ö·û´®²»½öÖµÏàµÈ£¬¶øÇÒ¶ÔӦλÖÃÉϳ¤¶ÈÏàµÈµÄ×Ö·ûÒ²ÏàµÈ¡£ 8£®Á½¸ö´®µÄ±È½Ïʵ¼ÊÉÏÊÇASCIIÂëµÄ±È½Ï¡£Á½¸ö´®´ÓµÚÒ»¸öλÖÃÉϵÄ×Ö·û¿ªÊ¼½øÐбȽϣ¬µ±µÚÒ»´Î³öÏÖASCIIÂë´óµÄ´®Îª´ó£¬Èô±È½Ï¹ý³ÌÖгöÏÖÒ»¸ö×Ö·û´®½áÊøµÄÇé¿ö£¬ÔòÁíÒ»¸ö´®Îª¡¢½Ï´óÕß¡£ 9£®´®µÄ˳Ðò´æ´¢½á¹¹¾ÍÊÇ°Ñ´®Ëù°üº¬µÄ×Ö·ûÐòÁУ¬ÒÀ´Î´æÈËÁ¬ÐøµÄ´æ´¢µ¥ÔªÖÐÈ¥¡£ 10£®ÓÐЩ¼ÆËã»úϵͳÖÐΪÁ˳ä·ÖÀûÓô洢¿Õ¼ä£¬ÔÊÐíÒ»¸ö´æ´¢µ¥Ôª¿ÉÒÔ´æ·Å¶à¸ö×Ö ·û£¬´®µÄÕâÖÖ´æ´¢·½Ê½ÊÇÒ»ÖÖ½ôËõʽ´æ´¢·½Ê½¡£ 11£®´®µÄ·Ç½ôËõ´æ´¢·½Ê½ÊÇÒÔ´æ´¢µ¥ÔªÎª´æ´¢µ¥Î»£¬Ò»¸ö´æ´¢µ¥ÔªÖÐÖ»´æ·ÅÒ»¸ö×Ö·û¡£ÔÚÕâÖÖÇé¿öÏ£¬¼´Ê¹Ò»¸ö´æ´¢µ¥ÔªÄÜ´æ·Å¶à¸ö×Ö·û£¬ÕâʱºòÒ²Ö»´æ·ÅÒ»¸ö×Ö·û¡£ 12£®´®ÔڷǽôËõ·½Ê½Ï£¬´®³¤¶ÈµÄ´æ´¢ÊÇÒþʽµÄ£¬´®ËùÕ¼ÓõĴ洢µ¥ÔªµÄ¸öÊý¼´´®µÄ³¤¶È¡£ 13£®Ò»Ð©¼ÆËã»úÊÇÒÔ×Ö½ÚΪ´æÈ¡µ¥Î»£¬Ç¡ºÃÒ»¸ö×Ö·ûÕ¼ÓÃÒ»¸ö×Ö½Ú£¬×ÔÈ»ÐγÉÁËÿ¸ö´æ´¢µ¥Ôª´æ·ÅÒ»¸ö×Ö·ûµÄ·ÖÅ䷽ʽ£¬ÕâÖÖ·½Ê½¾ÍÊÇÒ»ÖÖµ¥×Ö½Ú´æ´¢·½Ê½¡£ÕâÖÖ·½Ê½Ò»°ã²»ÐèÒª´æ·Å´®³¤µÄ´æ´¢µ¥Ôª£¬¶øÐèÒªÒÔ³ÌÐòÖи÷±äÁ¿ÖµËù²»°üº¬µÄ×Ö·ûΪ½áÊø·û¡£ 14£®´®µÄÁ´Ê½´æ´¢½á¹¹Êǽ«´æ´¢ÇøÓò·Ö³ÉһϵÁдóСÏàͬµÄ½áµã£¬Ã¿¸ö½áµãÓÐÁ½¸ö³Ç£ºÊý¾ÝÓòºÍÖ¸ÕëÓò¡£ÆäÖÐÊý¾ÝÓòÓÃÓÚ´æ·ÅÊý¾Ý£¬Ö¸ÕëÓòÓÃÓÚ´æ·ÅÏÂÒ»¸ö½áµãµÄÖ¸Õë¡£ 15£®×Ó´®¶¨Î»StrIndex (s£¬t)£¬Ò²³ÆΪģʽƥÅ䣬ÊÇ·µ»Ø´®tÔÚsÖ÷´®ÖеÄλÖᣠÈý¡¢ÅÐ¶Ï»Ø 1£®×Ó´®ÊÇÖ÷´®ÖÐ×Ö·û¹¹³ÉµÄÓÐÏÞÐòÁС££¨´íÎó£º×Ó´®ÊÇÖ÷´®ÖÐÁ¬Ðø×Ö·û¹¹³ÉµÄÓÐÏÞÐòÁС£ £© 2£®KMPËã·¨µÄ×î´óÌصãÊÇָʾÖ÷´®µÄÖ¸Õë²»ÐèÒª»ØËÝ¡££¨ÕýÈ· £© 3£®´®ÖеÄÔªËØÖ»ÄÜÊÇ×Ö·û¡££¨ÕýÈ·£º×¢Òâ×Ö·û¿ÉÒÔÊÇ×Öĸ¡¢Êý×Ö»ò¼ÆËã»úÄܱí´ïµÄÆäËû·ûºÅ¡£ £© 4£®´®ÖеÄÔªËØÖ»¿ÉÄÜÊÇ×Öĸ¡££¨´íÎ󣺿ÉÒÔÊÇÊý×Ö»òÆäËû×Ö·û £© 5£®´®ÊÇÒ»ÖÖÌØÊâµÄÏßÐÔ±í¡££¨ÕýÈ· £© 6£®´®ÖпÉÒÔ°üº¬Óпհ××Ö·û¡££¨ ÕýÈ· £© 7£®´®µÄ³¤¶È²»ÄÜΪÁã¡££¨´íÎ󣺴®¿ÉÒÔÊÇ¿Õ´®¡¢³¤¶È¿ÉÒÔΪÁã £© 8£®Á½¸ö´®ÏàµÈ±ØÓд®³¤¶ÈÏàͬ¡££¨ ÕýÈ· £© 9£®Á½¸ö´®ÏàµÈÔò¸÷λÖÃÉÏ×Ö·û±ØÐë¶ÔÓ¦ÏàµÈ¡££¨ ÕýÈ· £© ËÄ¡¢×ÛºÏÌâ l£®±àдË㷨ʵÏÖ½«´ÜS1ÖÐµÄµÚ i¸ö×Ö·ûµ½µÚ j¸ö×Ö·ûÖ®¼äµÄ×Ö·û(²»°üÀ¨µÚ i¸ö×Ö·ûºÍµÚj¸ö×Ö·û)Ö®¼äµÄ×Ö·ûÓô®S2Ìæ»»¡£¼ÙÉè´®µÄ´æ´¢½á¹¹Îª£º ££define MAXSIZE 81 struct string{ int len£» char ch£ÛMAXSIZE£Ý£» £ýstringtype£» void replace (stringtype s1[], int i, int j, stringtype s2[]) { stringtype s[100]; int h,k; if ( i<=h && i 2£®Éè¼ÆÒ»¸öËã·¨£¬²âÊÔÒ»¸ö´®SÊÇ·ñ»ØÎÄ£¨Ëùν»ØÎÄÊÇÖ¸´Ó×óÃæ¶ÁÆðºÍ´ÓÓÒÃæ¶ÁÆðÄÚÈÝÒ»Ñù£©¡£ int invert(stringtype *s) { /*ÅжÏÊÇ·ñ»ØÎÄ*/ int i, j; j=length(s)%2; for ( i=0; i 3£®Ð´Ò»¸öµÝ¹éËã·¨À´ÊµÏÖ×Ö·ûµÄÄæÐò´æ´¢£¬ÒªÇó²»ÁíÉè´æ´¢¿Õ¼ä¡£ SubStr(s, void reverse ( stringtype *s ) { char c; int i; i=1; printf(\ do { scanf(\ Reverse(s); s.ch[i]=c; i++; }while(c!='#'&&i 4£®Ò»¸ö½öÓÉ×Öĸ×é³ÉµÄ×Ö·û´®s£¬³¤¶ÈΪn£¬Æä½á¹¹Îªµ¥Á´±í£¬Ã¿¸ö½áµãµÄÊý¾Ý³ÇÖ»´æ·ÅÒ»¸ö×Öĸ¡£Éè¼ÆÒ»¸öËã·¨£¬È¥µô×Ö·û´®ÖÐËùÓÐֵΪXµÄ×Öĸ¡£ void sjt4( linklist *s, char x ) { linklist *p,*q,*r; int w; p=s; w=1; while ( p!=NULL ) { if ( w==1 ) /*´¦ÀíµÚÒ»¸ö½áµã*/ if(p->data==x)/*ɾ³ýµÚÒ»¸ö½áµã*/ { s=p->next; free(p); p=s; } else { q=p; p=p->next; w=0; } else /*´¦ÀíÆäËû½áµã*/ { if ( p->data==x) /*ɾ³ýֵΪxµÄ½áµã*/ { q->next=p->next; free (p); p=q->next; } else { q=p; p=p->next; } } } } /*sjt4*/ Ï°ÌâÎå Ò»¡¢Ñ¡ÔñÌâ l£®Êý×é³£ÓõÄÁ½ÖÖ»ù±¾²Ù×÷ÊÇ£¨ £©¡£ A£®½¨Á¢Óë²éÕÒ B£®É¾³ýÓë²éÕÒ C£®²åÈËÓëË÷Òý D£®²éÕÒÓëÐÞ¸Ä 2£®¶ÔÏ¡Êè¾ØÕó½øÐÐѹËõ´æ´¢£¬³£ÓõÄÁ½ÖÖ·½·¨ÊÇ£¨ £©¡£ A£®¶þÔª×éºÍÉ¢Áбí B£®ÈýÔª×éºÍÊ®×ÖÖý±í C£®Èý½Ç¾ØÕóºÍ¶Ô½Ç¾ØÕó D£®¶Ô½Ç¾ØÕóºÍÊ®×ÖÁ´±í 3£®²ÉÓÃÏ¡Êè¾ØÕóµÄÈýÔª×é±íÐÎʽ½øÐÐѹËõ´æ´¢£¬ÈôÒªÍê¶ÔÈýÔª×é±í½øÐгÉתÖã¬Ö»Òª½«ÐкÍÁжԻ»£¬ÕâÖÖ˵·¨£¨ £©¡£ A£®ÕýÈ· B£®´íÎó C£® ÎÞ·¨È·¶¨ D£®ÒÔÉϾù²»¶Ô 4£®Ò»¸ö¹ãÒå±íµÄ±íÍ·×ÜÊÇÒ»¸ö¹ãÒå±í£¬ÕâÖÖ˵·¨£¨ £©¡£ A£®ÕýÈ· B£®´íÎó C£®ÎÞ·¨È·¶¨ D£®ÒÔÉϾù²»¶Ô 5£®Ò»¸ö¹ãÒå±íµÄ±íβ×ÜÊÇÒ»¸ö¹ãÒå±í£¬ÕâÖÖ˵·¨£¨ £©¡£ A£®ÕýÈ· B£®´íÎó C£®ÎÞ·¨È·¶¨ D£®ÒÔÉϾù²»¶Ô 6£®¹ãÒå±í((a))µÄ±íÍ·ÊÇ£¨ £©¡£ A£®£¨ £© B£®a C£®£¨a£© D£®£¨£¨a£©£© 7£®¹ãÒå±í£¨£¨a£©£©µÄ±íβÊÇ£¨ £©¡£ A£®£¨£© B£®a C£®£¨a£© D£®£¨£¨a£©£© 8£®¹ãÒå±í£¨£¨a£©£¬a£©µÄ±íÍ·ÊÇ£¨ £©¡£ A£®£¨ £© B£®a C£®£¨a£© D£®£¨£¨a£©£© 9£®¹ãÒå±í£¨£¨a£©£¬a£©µÄ±íβÊÇ£¨ £©¡£ A£®( ) B£®a C£®£¨a£© D£®£¨£¨a£©£© 10£®¹ãÒå±í£¨a£¬b£¬c£©µÄ±íÍ·ÊÇ£¨ £©¡£ A£®a B£®£¨a£© C£®a£¬b D£®£¨a£¬b£© 11£®¹ãÒå±í£¨a£¬b£¬c£©µÄ±íβÊÇ£¨ £©¡£ A£®b£¬c B£®£¨b£¬c£© C£®a£®b£¬c D£®£¨a£¬b£¬c£© 12£®¹ãÒå±íAÂú×ãHead£¨£©= Tail£¨£©£¬ÔòAΪ£¨£©¡£ A£®£¨£© B£®£¨£¨£©£© C£¨£¨£©£¬£¨£©£© D£®£¨£¨£©£¬£¨£©£¬£¨£©£© ¶þ¡¢Ìî¿ÕÌâ 1£®Êý×飨array£©ÊÇn£¨n£¾1£©¸ö__________µÄÓÐÐò×éºÏ£¬Êý×éÖеÄÊý¾ÝÊÇ°´Ë³Ðò´æ´¢ÔÚÒ»¿é______________µÄ´æ´¢µ¥ÔªÖС£ 2£®Êý×éÖеÄÿһ¸öÊý¾Ýͨ³£³ÆΪ_____£¬________ÓÃϱêÇø·Ö£¬ÆäÖÐϱêµÄ¸öÊýÓÉÊý×éµÄ________________¾ö¶¨¡£ 3£®ÓÉÓÚ¼ÆËã»úÄÚ´æÖеĴ洢µ¥ÔªÊÇÒ»¸öһάµÄ´æ´¢½á¹¹£¬Òò´Ë¶ÔÓÚ¶àάÊý×éÒªÏ밴˳ Ðò´æ´¢µ½¼ÆËã»ú´æ´¢µ¥ÔªÖоͱØÐëÓÐÒ»¸öÅÅÁÐ˳ÐòÎÊÌâ¡£¶ÔÓÚ¶þάÊý×飬ÓÐÁ½ÖÖÅÅÁÐÐÎʽ£ºÒ»ÖÖÊÇ___________£»ÁíÒ»ÖÖÊÇ_____________¡£ 4£®¶ÔÓÚÐèҪѹËõ´æ´¢µÄ¾ØÕó¿ÉÒÔ·ÖΪ__________ºÍ_________¡£¶ÔÄÇЩ¾ßÓÐÏàֵͬԪËØ»òÁãÔªËØÔÚ¾ØÕóÖзֲ¼¾ßÓÐÒ»¶¨¹æÂɵľØÕó£¬ÎÒÃdzÆ֮Ϊ___________£»¶ø¶ÔÓÚÄÇЩÁãÔªËØÊýÄ¿Ô¶Ô¶¶àÓÚ·ÇÁãÔªËØÊýÄ¿£¬²¢ÇÒ·ÇÁãÔªËصķֲ¼Ã»ÓйæÂɵľØÕó³ÆΪ_____________¡£ 5£®ÔÚÒ»¸ön½×·½Õó aÖУ¬ÈôÔªËØÂú×ãÐÔÖÊ£ºaij£½a£¨j<=n-l£©£¬Ôò³ÆAΪn½×_______¡£ ji0<=i£¬6£®²ÉÓÃ˳Ðò´æ´¢½á¹¹±íʾÈýÔª×é±í(Trope Table)£¬ÒÔʵÏÖ¶ÔÏ¡Êè¾ØÕóµÄÒ»ÖÖѹËõ´æ´¢ÐÎʽ£¬³ÆΪ______________£¬¼ò³Æ________________±í¡£ 7£®________________ÔËËãÊǾØÕóÔËËãÖÐ×î»ù±¾µÄÒ»ÏËüÊǽ«Ò»¸öm*nµÄ¾ØÕó±ä³ÉÁíÍâÒ»¸ön*mµÄ¾ØÕó£¬Í¬Ê±Ê¹ÔÀ´¾ØÕóÖÐÔªËصÄÐкÍÁеÄλÖû¥»»¶øÖµ±£³Ö²»±ä¡£ 8£®¹ãÒå±íÊÇn£¨n>=0£©¸öÔªËصÄÐòÁС£¼Ç×÷£ºA£½£¨a1£¬a2£¬?£¬an£©£¬ÆäÖУ¬AÊǹãÒå±íµÄ_________£¬nÊÇËüµÄ_________£¬µ±n=0µÄʱºò³ÆΪ____________¡£ 9£®ÔÚÒ»¸ö·Ç¿ÕµÄ¹ãÒå±íÖУ¬ÆäÔªËØai¿ÉÒÔÊÇijһȷ¶¨ÀàÐ͵ĵ¥¸öÔªËØ£¬³ÆΪ__________£¬Ò²¿ÉÒÔÓÖÊÇÒ»¸ö¹ãÒå±í£¬³ÆΪ_____________________¡£ 10£®¹ãÒå±íµÄ¶¨ÒåÊÇÒ»ÖֵݹéµÄ¶¨Ò壬¹ãÒå±íÊÇÒ»ÖֵݹéµÄÊý¾Ý½á¹¹¡£µ±¹ãÒå±í·Ç¿ÕµÄʱºò£¬³ÆµÚÒ»¸öÔªËØalΪ¹ãÒå±íAµÄ__________£¬³ÆÆäÓàÔªËØ×é³ÉµÄ±í£¨a2£¬a3£¬?£¬an£©ÊÇAµÄ______________¡£ 11£®¹ãÒå±íµÄÉî¶ÈÒ»°ã¶¨ÒåΪ¹ãÒå±íÔªËØ_________£¬»òÕß˵ÊǹãÒå±í___________¡£ÀûÓõݹéµÄ¶¨Ò壬¹ãÒå±íµÄÉî¶È¾ÍÊÇËùÓÐ×Ó±íÖÐ_________________________¡£ Èý¡¢ÅжÏÌâ 1£®Ê®×ÖÁ´±í²»ÊÇ˳Ðò´æ´¢½á¹¹¡££¨ £© 2£®ÈýÔª×é±í²»ÊÇÒ»¸öËæ»ú´æ´¢½á¹¹¡££¨ £© 3£®Ï¡Êè¾ØÕóѹËõ´æ´¢ºó£¬±ØÈ»»áʧȥËæ»ú´æÈ¡¹¦ÄÜ¡££¨ £© 4£®ÈôÒ»¸ö¹ãÒå±íµÄ±íͷΪ¿Õ±í£¬Ôò´Ë¹ãÒå±íҲΪ¿Õ±í¡££¨ £© 5£®¹ãÒå±íÊÇÏßÐÔ±íµÄÍƹ㣬ÊÇÒ»ÀàÏßÐÔÊý¾Ý½á¹¹¡££¨ £© 6£®ÈκÎÒ»¸ö·Ç¿Õ¹ãÒå±í£¬Æä±íÍ·¿ÉÄÜÊǵ¥ÔªËØ»ò¹ãÒå±í£¬Æä±íβ±Ø¶¨ÊǹãÒå±í¡£ £¨ £© 7£®Ò»¸öÏ¡Êè¾ØÕóAm*n²ÉÓÃÈýÔª×éÐÎʽ±íʾ£¬Èô°ÑÈýÔª×éÖÐÓйØÐÐϱêÓëÁÐϱêµÄÖµ»¥»»£¬²¢°ÑmºÍnµÄÖµ»¥»»£¬Ôò¾ÍÍê³ÉÁËAm*nµÄתÖÃÔËËã¡££¨ £© 8£®Êý×éÖÐÿ¸öÔªËرض¨¾ßÓÐÏàͬµÄÊý¾ÝÀàÐÍ¡££¨ £© 9£®ÏßÐÔ±íÊǹãÒå±íµÄÌØÀý¡££¨ £© 10£®Èç¹û¹ãÒå±íÖеÄÿ¸öÔªËض¼ÊÇÔ×Ó£¬Ôò¹ãÒå±í±ã³ÉΪÏßÐÔ±í¡££¨£© 11£®¹ãÒå±íÖÐÔ×Ó¸öÊý¼´Îª¹ãÒå±íµÄ³¤¶È¡££¨£© 12£®¹ãÒå±í×î´ó×Ó±íµÄÉî¶ÈΪ¹ãÒå±íµÄÉî¶È¡££¨£© 13£®¹ãÒå±íÖÐÔªËØ×î´óµÄ²ãÊý³ÆΪ¹ãÒå±íµÄÉî¶È¡££¨£© 14£®¹ãÒå±íÊÇÒ»ÖÖ¶à²ã´Î½á¹¹¡££¨£© 15£®¹ãÒå±íÊÇÒ»ÖÖÏßÐԽṹ¡££¨£© 16£®¹ãÒå±íÊÇÒ»ÖÖ¹²Ïí½á¹¹¡££¨£© 17£®¹ãÒå±íÊÇÒ»Öֵݹé½á¹¹¡££¨£© 18£®¹ãÒå±íÊÇÒ»ÖÖµ¥Á´±í½á¹¹¡££¨£© ËÄ¡¢×ÛºÏÌâ 1£®ÓöþάÊý×éʵÏÖ¡°Ä§·½Õ󡱵ĴòÓ¡£¬Ëùν¡°Ä§·½½µ¡¯ÊÇÖ¸Âú×ãÿһÐС¢Ã¿Ò»ÁкͶԽÇÏßÉϵÄÔªËØÖ®ºÍ¾ùÏàµÈµÄ·½Õó¡£ÀýÈ磺 8 1 6 3 5 7 4 9 2 ¾ÍÊÇÒ»¸öÈý½×µÄħ·½Õó¡£ÏÖÔÚÒªÇó±à³ÌʵÏÖÈÎÒâÊäÈËÒ»¸ö×ÔÈ»Êýn£¬´òÓ¡³öÏàÓ¦µÄn½×ħ·½Õó¡£ void MagicMatrix( ) { int a[16][16],i,j,k,p,m,n; p=1; while(p==1) /*ÊäÈë1¡«15µÄÆæÊý*/ { printf(\ scanf(\ if ((n!=0) && (n<=15) &&(n%2 !=0)) p=0; } /*Initialization*/ for ( i=1;i<=n;i++) for( j=1;j<=n;j++) a[i][j]=0; /*½¨Á¢Ä§·½Õó*/ j=n/2+1; a[1][j]=1; for (k=2; k<=n*n;k++) { i=i-1; j=j+1; if ((i<1) && (j>n)) { i=i+2; j=j-1; } else { if (i<1) i=n; if (j>n) j=1; } if (a[i][j]==0) a[i][j]=k; else { i=i+2; j=j-1; a[i][j]=k; } } /*Êä³öħ·½Õó*/ for (i=1; i<=n; i++ ) { for(j=1;j<=n;j++) printf(\ printf(\ } }/*MagicMatrix*/ 2£®ÕÒ³ö²¢´òÓ¡Ò»¸ö¶þάÊý×éÖеİ°µã£¬Ëùν°°µãÊÇÖ¸¸ÃλÖÃÉϵÄÔªËØÔÚ¸ÃÐÐÉÏ×î´ó£¬ÔÚ¸ÃÁÐÉÏ×îС¡£ #define N 10 #define M 10 void Andian( ) { int i,j,m,n,flag1,flag2,a[N][M], max, maxi, maxj; printf(\ scanf(\ printf(\input the column number :\\n\ scanf(\ for (i=0; i is:%d \\n\ flag2=1; } } if (!flag2) printf(\is no this kind of number.\\n\ }/*Andian*/ 3£®Ð´Ò»¸ö´´½¨Ï¡Êè¾ØÕóÏàÓ¦ÈýÔª×éµÄËã·¨¡£ #define MAXSIZE 1000 /*¼ÙÉè·ÇÁãÔª¸öÊýµÄ×î´óÖµÊÇ1000*/ typedef struct { int i, j; elemtype v; }triple; typedef struct { triple data[MAXSIZE+1]; /*data[0]ÓÃÓÚ´æ·ÅÏ¡Êè¾ØÕóÐУ¬ÁкͷÇÁãÔª¸öÊý*/ int mu, nu, tu; /*Ï¡Êè¾ØÕóÐС¢ÁкͷÇÁãÔªµÄ¸öÊý*/ } spmatrix; spmatrix a; void CreatTripleTable (int array_a[M][N],spmatrix a) /*array_aÊÇÒ»¸öÏ¡Êè¾ØÕó,aÊDzúÉúµÄÏà¶ÔÓ¦µÄÈýÔª×é´æ´¢*/ { int i,j,k=1; for (i=0;i } a.data[0][0]=M; a.data[0][1]=N; a.data[0][2]=k-1;/*´æÈë·Ç0ÔªËظöÊý*/ }/*CreatTripleTable*/ 4£®¼ÙÉèÈýÔª×éÔªËØֵΪÕûÐÍ£¬Ð´Ò»¸ö²éÕÒÈýÔª×éÔªËØֵΪnµÄËã·¨¡£ #define MAXSIZE 1000 /*¼ÙÉè·ÇÁãÔª¸öÊýµÄ×î´óÖµÊÇ1000*/ typedef struct { int i, j; elemtype v; }triple; typedef struct { triple data[MAXSIZE+1]; /*data[0]ÓÃÓÚ´æ·ÅÏ¡Êè¾ØÕóÐУ¬ÁкͷÇÁãÔª¸öÊý*/ int mu, nu, tu; /*Ï¡Êè¾ØÕóÐС¢ÁкͷÇÁãÔªµÄ¸öÊý*/ } spmatrix; spmatrix a; int SearchTripleTable(spmatrix a, int n) { int i,tu; tu=a.tu; /*·Ç0ÔªËظöÊý*/ i=1; while (i<=tu && a.data[i].v!=n) i++; /*²éÕÒµÈÓÚnµÄÔªËØÖµ*/ if (i<=tu) return(1); else return(0); }/*SearchTripleTable*/ 5. #define MAXSIZE 1000 /*¼ÙÉè·ÇÁãÔª¸öÊýµÄ×î´óÖµÊÇ1000*/ typedef struct { int i, j; elemtype v; }triple; typedef struct { triple data[MAXSIZE+1]; /*data[0]ÓÃÓÚ´æ·ÅÏ¡Êè¾ØÕóÐУ¬ÁкͷÇÁãÔª¸öÊý*/ int mu, nu, tu; /*Ï¡Êè¾ØÕóÐС¢ÁкͷÇÁãÔªµÄ¸öÊý*/ } spmatrix; void TripleTableAdd(spmatrix triple_a,spmatrix triple_b,spmatrix triple_c) { int i=1,j=1,k=1; if ((triple_a.mu !=triple_b.mu)|| (triple_b.nu != triple_b.nu) ) { printf(\άÊý²»Í¬£¬²»ÄÜÏà¼Ó¡£\\n\ exit(0); } else /*Âú×ãÏà¼ÓÌõ¼þ*/ { while (i<=triple_a.tu && j<=triple_b.tu) /*±È½Ïtriple_aµÄµ±Ç°ÏîµÄÐкÅÓëtriple_bµÄµ±Ç°ÏîµÄÐкÅ*/ { if (triple_a.data[i].i == triple_b.data[j].i) /*ÈôÐкÅÏàµÈ*/ if (triple_a.data[i].j < triple_b.data[j].j) /*±È½ÏÁ½ÈýÔª×éÁкÅ*/ { triple_c.data[k].i = triple_a.data[i].i; triple_c.data[k].j = triple_a.data[i].j; triple_c.data[k].v = triple_a.data[i].v; k++; i++; } /*triple_cÖдæÈë½ÏСÁеÄÏî*/ else if (triple_a.data[i].j > triple_b.data[j].j) { triple_c.data[k].i = triple_b.data[j].i; triple_c.data[k].j = triple_b.data[j].j; triple_c.data[k].v = triple_b.data[j].v; k++; j++; } else /*Èç¹ûÁкÅÒ²ÏàµÈ,Ôò½«¶ÔÓ¦µÄÔªËØÖµÏà¼Óºó´æÈëtriple_cÖÐ*/ { triple_c.data[k].i = triple_b.data[j].i; triple_c.data[k].j = triple_b.data[j].j; triple_c.data[k].v = triple_a.data[i].v+triple_b.data[j].v; k++; i++; j++; } else if (triple_a.data[i].i < triple_b.data[j].i) /*Èôtriple_aµÄµ±Ç°ÏîµÄÐкÅСÓÚtriple_bµÄµ±Ç°ÏîµÄÐкÅ*/ /*Ôò½«triple_aµÄÏîtriple_cÖÐ*/ { triple_c.data[k].i = triple_a.data[i].i; triple_c.data[k].j = triple_a.data[i].j; triple_c.data[k].v = triple_a.data[i].v; k++; i++; } else /*Èôtriple_aµÄµ±Ç°ÏîµÄÐкŴóÓÚtriple_bµÄµ±Ç°ÏîµÄÐкÅ*/ /*Ôò½«triple_bµÄÏî´æÈëtriple_cÖÐ*/ { triple_c.data[k].i = triple_b.data[j].i; triple_c.data[k].j = triple_b.data[j].j; triple_c.data[k].v = triple_b.data[j].v; k++; j++; } } triple_c.mu=triple_a.mu; /*²úÉúµÚ0ÐеĽá¹û*/ triple_c.nu=triple_a.nu; triple_c.tu=k-1; } }/*TripleTableAdd*/ 5£®ÓÐÁ½¸öÏ¡Êè¾ØÕóµÄÈýÔª×étriple_aºÍtriple_b£¬Çëд³öÀûÓÃÈýÔª×éÕâÖÖÊý¾Ý½á¹¹£¬ÊµÏÖ½«Á½¸öÏ¡Êè¾ØÕóÏà¼Ó£¬×îºóµÄºÍ´æÈëÈýÔª×é±ítriple_cÖ®ÖеÄËã·¨¡£ #define MAXSIZE 1000 /*¼ÙÉè·ÇÁãÔª¸öÊýµÄ×î´óÖµÊÇ1000*/ typedef struct { int i, j; elemtype v; }triple; typedef struct { triple data[MAXSIZE+1]; /*data[0]ÓÃÓÚ´æ·ÅÏ¡Êè¾ØÕóÐУ¬ÁкͷÇÁãÔª¸öÊý*/ int mu, nu, tu; /*Ï¡Êè¾ØÕóÐС¢ÁкͷÇÁãÔªµÄ¸öÊý*/ } spmatrix; int TripleValue(spmatrix c, int i, int j) /*¸Ãº¯ÊýÓÃÔÚTripleMulº¯ÊýÖ®ÖÐ,¼ÆËãÈýÔª×écÏàÓ¦µÄÖµ*/ { int k=1; while (k<=c.tu && (c.data[k].i!=i || c.data[k].j!=j)) k++; if (k<=c.tu) return(c.data[k].v); /*ÕÒµ½ÁË·µ»Ø¸ÃλÖõÄÖµ*/ else return(0); /*δÕÒµ½ËµÃ÷¸ÃÔªËØΪ0*/ }/*TripleValue*/ void TripleMul(int m,int n,int k,spmatrix a,spmatrix b,spmatrix c) { int i,j,h,p=1,s; for (i=0;i }/*TripleMul*/ 6£®ÓÐÁ½¸öÏ¡Êè¾ØÕóµÄÈýÔª×étriple_aºÍtriple_b£¬Çëд³öÀûÓÃÈýÔª×éÕâÖÖÊý¾Ý½á¹¹£¬ÊµÏÖ½«Á½¸öÏ¡Êè¾ØÕóÏà³Ë£¬²¢½«×îºóµÄ³Ë»ý´æÈ˶þÔª×é±ítriple_cÖ®ÖеÄËã·¨¡£