资源描述:
《动物识别系统-----景如峰(06041024)》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、动物识别系统-----景如峰(06041024)用法:根据系统的提示逐步输入Y或者N来进行推理,直到推出结论。程序下:#include #include #include #include #define True 1#define False 0#define DontKnow -1char *str[]={"chew_cud反刍","hooves有蹄子","mammal哺乳动物","forward_eyes向前的眼睛","claws有爪","pointed_teeth有犬齿","eat_meat吃肉","l
2、ay_eggs下蛋","fly飞","feathers羽毛","ungulate有蹄的","carnivore食肉动物","bird鸟","give_milk有奶","has_hair有毛","fly_well飞得很好?","black&white_color","can_swim","long_legs","long_neck","black_stripes黑色","dark_spots黑斑","tawny_color茶色","albatross鹰","penguin企鹅","ostrich鸵鸟","zebra斑马","giraffe长颈鹿","tiger老虎","cheetah猎豹"
3、,0};int rulep[][6]={{22,23,12,3,0,0},{21,23,12,3,0,0},{22,19,20,11,0,0},{21,11,0,0,0,0},{17,19,20,13,-9,0},{17,18,13,-9,0,0},{16,13,0,0,0,0},{15,0,0,0,0,0},{14,0,0,0,0,0},{10,0,0,0,0,0},{8,7,0,0,0,0},{7,0,0,0,0,0},{4,5,6,0,0,0},{2,3,0,0,0,0},{1,3,0,0,0,0}};//产生式规则int rulec[]={30,29,28,27,26,25,24
4、,3,3,13,13,12,12,11,11,0};//结论class fact{private: int Number; char Name[21]; int Active; int Succ;public: fact *Next; fact(int Num,char *L) { strcpy(Name,L); Number=Num; Active=False; //-1是已经推理,不符合。1是已经推理,符合。 Succ=DontKnow; /
5、/0是无,-1是不知道,1是有。 Next=NULL; } char *GetName() { char *L; L=new char[21]; strcpy(L,Name); return L; } int GetNumber() { return Number; } int GetAct() { return Active; } int GetSucc() { return Succ; } void PutAct(
6、const int Act0,int Suc0) { Active=Act0; Succ=Suc0; }};fact *Fact;class list{private: int Number;public: list *Next; list(int Num) { Number=Num; Next=NULL; } int GetNumber() { return Number; }};class rule{char *Name;list *Pre;int Conc;public: r
7、ule *Next; rule(char *N,int P[],int C); ~rule(); int Query(); void GetName() { cout<Next; delete Pre; Pre=L;}delete Name;}rule::rule(char *N,int P[],int C){