資源簡介
人工智能中,野人與傳教士問題C語言程序實現
代碼片段和文件信息
#include??
#include??
#define?maxloop?100?/*?最大層數,對于不同的擴展方法自動調整取值?*/?
#define?pristnum?3?
#define?slavenum?3?
struct?SPQ{?int?srpr;?/*?船運行一個來回后河右岸的野人、傳教士的人數?*/?
int?slpl;?/*?船運行一個來回后河左岸的野人、傳教士的人數?*/?
int?ssrspr;?/*?回來(由左向右時)船上的人數?*/?
int?sstspt;?/*?去時(由右向左時)船上的人數?*/?
int?loop;?/*?本結點所在的層數?*/?
struct?SPQ?*upnode?*nextnode;/*?本結點的父結點和同層的下一個結點的地址?*/?
}spq;?
int?loopnum;/*?記錄總的擴展次數?*/?
int?openednum;/*?記錄已擴展節點個數?*/?
int?unopenednum;/*?記錄待擴展節點個數?*/?
int?resultnum;?
struct?SPQ?*opened;?
struct?SPQ?*oend;?
struct?SPQ?*unopened;?
struct?SPQ?*uend;?
struct?SPQ?*result;?
void?initiate();?
void?releasemem();?
void?showresult();?
void?addtoopened(struct?SPQ?*ntx);?
int?search();?
void?goon();?
int?stretch(struct?SPQ*?ntx);?
void?recorder();?
voi
評論
共有 條評論