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

CÓïÑÔµÄÒ»¸ö¼òµ¥Ëã·¨: 26¸ö×ÖĸËæ»ú²½Éú³É

Ò»¸ö¼òµ¥µÄС³ÌÐò, Ô­ÌâÄ¿¼û<CÓïÑÔ³ÌÐòÉè¼Æ-ÏÖ´ú·½·¨>µÚ°ËÕÂÁ·Ï°13.
ÓÉÓÚ×Ô¼ºÖ»¿´µ½µÚ°ËÕÂ, ËùÒÔ, ²»¸ÒóȻʹÓú¯ÊýµÈÆäËûÄÚÈÝ, ¸ßÊÖÇë·ÅÉù´óЦ.
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#define ROWS 10
#define COLS 10
/**
* @author: selfimpr
* @blog: http://blog.csdn.net/lgg201
* @email: lgg860911@yahoo.com.cn
* ¹¦ÄÜ:
* ROWS * COLSµÄ·½¸ñÖÐʵÏÖËæ»ú²½. ¼´½«26¸ö´óд×Öĸ°´Ë³ÐòÒÔËæ»úµÄ·½ÏòÅÅÁÐ.
* ÕâÀïʵÏÖµÄÊǰ˸ö·½Ïò(º¹, ²»ÖªµÀÓÐûÓа˸ö·½Ïòһ˵.)
* ȱÏÝ:
* Óнϴó¼¸Âʱ»À§ËÀ, ûÓÐ×öÓÅ»¯´¦Àí.
* Êý¾Ý½á¹¹Éè¼Æ:
* 1. ROWS, COLSºê¶¨ÒåÁËÆåÅ̵ĴóС
* 2. board¶þάÊý×鶨ÒåÁËÆåÅÌ, ûÓÐ×ÖĸµÄÒÔ.ºÅ²¹¿Õ
* 3. i, jΪѭ»·Òò×Ó, ÔÚ·½Ïò¿ØÖÆʱ, ³äµ±ÁËÒƶ¯µÄ·½Ïò¿ØÖÆ.
* 4. directionΪ·½Ïò¿ØÖƱäÁ¿.
* 5. chÊÇ˳Ðò»ñÈ¡×ÖĸµÄÑ­»·Òò×Ó.
* 6. row, col´æ´¢ÁÙʱµÄÒƶ¯×ø±ê, ´æ´¢¸Ã×ø±êΪÁ˱£Ö¤»ñÈ¡µÄ·½Ïò²»¿ÉÓÃʱ, ²»Ó°ÏìÔ­Êý¾Ý.
* Á÷³Ì:
* 1. ³õʼ»¯ÆåÅÌ, ÒÔ.ºÅ³õʼ»¯ËùÓÐÔªËØ, ´òÓ¡Ò»´Î¿ÕÆåÅ̺ó, ½«ÆåÅÌ[0, 0]×ø±êÔªËØÉèÖÃΪ'A'.
* 2. ÉèÖÃËæ»úÊýÉú³ÉÖÖ×ÓΪµ±Ç°Ê±¼ä, ÒÔ±£Ö¤Ã¿´ÎÉú³ÉµÄËæ»úÊý²»Í¬.
* 2. Ñ­»·´¦Àí×Öĸ
* 3. »ñÈ¡Ëæ»ú·½Ïò, ²¢¸ù¾Ý·½ÏòÈ¡µÃÒƶ¯ºóµÄ×ø±ê, ±£´æµ½ÁÙʱ±äÁ¿rowºÍcolÖÐ.
* 4. ÅжÏеÄ×ø±êÊÇ·ñÓÐЧ
* 5. Èç¹ûÐÂ×ø±ê²»¿ÉÓÃ, µ½µÚ3²½ÖØлñÈ¡·½Ïò.
* 6. Èç¹ûÐÂ×ø±êÓÐЧ:
* 6.1. ÉèÖÃÆåÅ̶ÔӦλÖõÄ×Öĸ
* 6.2. ½«ÁÙʱ×ø±êÐÅϢת´æµ½ÕæÕýµÄµ±Ç°×ø±êi, jÖÐ.
* 6.3. »ñÈ¡ÏÂÒ»¸ö×Öĸ
* 6.4. µ½µÚ2²½ÖØпªÊ¼´¦ÀíÏÂÒ»¸ö×Öĸ.
* 7. ´òÓ¡×îºóÉú³ÉµÄÆåÅÌ.
*
*/
int main() {
char board[ROWS][COLS];
int i, j, direction;
srand( (unsigned) time(NULL));
for(i = 0; i < ROWS; i ++) {
for(j = 0; j < COLS; j ++) {
board[i][j] = '.';
}
}
for(i = 0; i < ROWS; i ++) {
for(j = 0; j < COLS; j ++) {
printf("%c ", board[i][j]);
}
printf("\n");
}
board[0][0] = 'A';
printf("\n");
char ch;
i = 0; j = 0;
int row = 0, col = 0;
for(ch = 'B'; ch <= 'Z';) {
direction = rand() % 8;
switch(directio


Ïà¹ØÎĵµ£º

ÉîÈëÀí½âextern "C"

Ò»¡¢´ÓCÓëC++±àÒëÁ¬½Ó·½Ê½ÉîÈëÀí½âextern "C"
<1>.CºÍC++¶Ôº¯ÊýµÄ´¦Àí·½Ê½ÊDz»Í¬µÄ.±»extern "C"ÐÞÊεıäÁ¿ºÍº¯ÊýÊÇ°´ÕÕCÓïÑÔ·½Ê½±àÒëºÍÁ¬½ÓµÄ.extern "C"ÓÃÓÚʵÏÖC++ÓëC¼°ÆäËüÓïÑԵĻìºÏ±à³Ì¡£
<2>.δ¼Óextern “C”ÉùÃ÷ʱµÄ±àÒ뷽ʽ
Ê×ÏÈ¿´¿´C++ÖжÔÀàËÆCµÄº¯ÊýÊÇÔõÑù±àÒëµÄ¡£
×÷ΪһÖÖÃæÏò ......

ÉîÈëÀí½âCÓïÑÔÖ¸ÕëµÄ°ÂÃØ¡¾×ªÌû¡¿

http://www.kuqin.com/language/20090314/39862.html
Ö¸ÕëÊÇÒ»¸öÌØÊâµÄ±äÁ¿£¬ËüÀïÃæ´æ´¢µÄÊýÖµ±»½âÊͳÉΪÄÚ´æÀïµÄÒ»¸öµØÖ·¡£ Òª¸ãÇåÒ»¸öÖ¸ÕëÐèÒª¸ãÇåÖ¸ÕëµÄËÄ·½ÃæµÄÄÚÈÝ£ºÖ¸ÕëµÄÀàÐÍ£¬Ö¸ÕëËùÖ¸ÏòµÄ ÀàÐÍ£¬Ö¸ÕëµÄÖµ»òÕß½ÐÖ¸ÕëËùÖ¸ÏòµÄÄÚ´æÇø£¬»¹ÓÐÖ¸Õë±¾ÉíËùÕ¼¾ÝµÄÄÚ´æÇø¡£ÈÃÎÒÃÇ·Ö±ð˵Ã÷¡£
¡¡¡¡ ÏÈÉùÃ÷¼¸¸öÖ¸Õë·Å×Å×öÀý× ......

CÓïÑԺ궨Òå¼¼Çɼ°×¢ÒâÎÊÌâ abstract

Ç°ÑÔ
ÔÚ±àд³ÌÐòµÄʱºò,ÎÒÃǾ­³£ÒªÓõ½ºê¶¨Òå,ºê¶¨ÒåµÄÒýÈëȷʵ´ó´óÌá¸ßÁ˳ÌÐòµÄ¿É¶ÁÐÔ,¿ÉÒÆÖ²ÐÔ,·½±ãά»¤.......Òò´ËƯÁÁµÄºê¶¨ÒåºÜÖØÒª.....ʹÓú궨ÒåÒ²ÊÇÓÐÒ»¶¨¼¼ÇɵÄ,ÏÂÃæÊǹØÓں궨ÒåµÄһЩºÃµÄ³£Óõķ½·¨,¾Ý˵ÊÇһЩ³ÉÊìµÄÈí¼þÖг£ÓõÄ....ÎÒÌôÁËһЩÎÒÃÇÄܹ»Àí½â¶øÇÒʵÓõãµÄ.... µ«ÊÇ,ʹÓú궨ÒåʱҲҪʮ·ÖСÐÄ,Ó ......

C/C++ÖÐmallocºÍnewµÄÇø±ð


¡¡¡¡1£¬mallocÓëfreeÊÇC++/CÓïÑԵıê×¼¿âº¯Êý£¬new/deleteÊÇC++µÄÔËËã·û¡£ËüÃǶ¼¿ÉÓÃÓÚÉêÇ붯̬ÄÚ´æºÍÊÍ·ÅÄÚ´æ¡£
¡¡¡¡2£¬¶ÔÓÚ·ÇÄÚ²¿Êý¾ÝÀàÐ͵ĶÔÏó¶øÑÔ£¬¹âÓÃmaloc/freeÎÞ·¨Âú×㶯̬¶ÔÏóµÄÒªÇ󡣶ÔÏóÔÚ´´½¨µÄͬʱҪ×Ô¶¯Ö´Ðй¹Ô캯Êý£¬¶ÔÏóÔÚÏûÍö֮ǰҪ×Ô¶¯Ö´ÐÐÎö¹¹º¯Êý¡£ÓÉÓÚmalloc/freeÊǿ⺯Êý¶ø²»ÊÇÔËËã·û£¬²»ÔÚ±àÒëÆ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ