资源简介
从那三个txt文档读出数据,然后根据自己写的算法,从正向和反向推理来的识别用户所描述是什么动物。

代码片段和文件信息
#include
#include
#include
#include
#define MAXNUM 50
typedef struct
{
int xuh;
char valu[50];
}Node;
typedef struct
{
int stat;//0:还未访问 1:至少用过一次 2:没用过但不冲突
int xuh;
}NFact;
typedef struct
{
int snum;//开始时的事实数
int curnum;//目前的事实数
int notEnoughFlag;//当最后若所有未用过的条件支持一个结论,但条件不足时,置1
NFact cod[MAXNUM];
}Fact;
typedef struct
{
int rslt;
int codNum;//记载前提的个数
int cod[10];//记载前提的序号
int used;//记载是否已匹配成功
}Nrule;
typedef struct
{
int codXuh;
int stat;
double weight;
int rslt;
//int codNum;
}bQueueNode;
typedef struct
{
int head;
int tail;
bQueueNode bNode[MAXNUM];
}bQueue;
typedef struct
{
int canReachTime;
int havReached;
}Reach;
typedef struct
{
int lastCodXuhInQueue;
int myXuh;
//int mycodNum;
int myRslt;
double myweight;
}CloseNode;
typedef struct
{
int head;
int tail;
CloseNode node[MAXNUM];
}Close;
int codnum=28;
int goalnum=7;
int rulenum=0;
Node goal[20];
Node cod[50];
Nrule rule[50];
Fact inpCod;
bQueue bqueue;
Reach recReach[MAXNUM];
Close close;
void readGoal()
{
FILE *fp;
int i;
if((fp=fopen(“goal.txt““r“))==NULL)
{
printf(“cannot open goal\n“);
exit(0);
}
i=0;
while((fscanf(fp“%d %s“&goal[i].xuh&goal[i++].valu))!=EOF);
fclose(fp);
}//readGoal
void readRule()
{
FILE *fp;
int i;
int tempxuhtempcodn;
char ch;
if((fp=fopen(“rules.txt““r“))==NULL)
{
printf(“cannot open data\n“);
exit(0);
}
i=0;
rule[i].codNum=0;
while((ch=fgetc(fp))!=EOF)
{
if(i==14)
i=i;
tempcodn=0;
while(ch!=‘\n‘&&ch!=EOF) //每一条规则
{
tempxuh=0;
while(ch<=‘9‘&&ch>=‘0‘)
{
tempxuh=tempxuh*10+ch-‘0‘;
ch=fgetc(fp);
}
rule[i].cod[tempcodn++]=tempxuh;
tempxuh=0;
if(ch==‘-‘)//下一个是结论
{
ch=fgetc(fp);
ch=fgetc(fp);
while(ch<=‘9‘&&ch>=‘0‘)
{
tempxuh=tempxuh*10+ch-‘0‘;
ch=fgetc(fp);
}
rule[i].rslt=tempxuh;
}//if
else if(ch==‘*‘)
{
ch=fgetc(fp);
}
rule[i].codNum++;
}
i++;
}
rulenum=i;
fclose(fp);
}//readCod
void readCod()
{
FILE *fp;
int i;
if((fp=fopen(“data.txt““r“))==NULL)
{
printf(“cannot open data\n“);
exit(0);
}
i=0;
while((fscanf(fp“%d %s“&cod[i].xuh&cod[i++].valu))!=EOF);
fclose(fp);
}//readCod
void readFiles()
{
//char fname[100];
readGoal();
readCod();
readRule();
}//reaFiles
int inputCod()
{
int retflag=1;
int temp;
int i;
i=0;
do
{
scanf(“%d“&temp);
inpCod.cod[i++].xuh=temp;
if(temp>=codnum)
{
printf(“特征序号不能大于%d请重新输入:\n“codnum-1);
fflush(stdin);
retflag=0;
}
}while(temp!=-1&&temp inpCod.snum=i-1;
inpCod.curnum=inpCod.snum;
/*inpCod.snum=5;
inpCod.curnum=inpCod.snum;
inpCod.cod[0].xuh=1;
inpCod.cod[1].xuh=5;
inpCod.cod[2].xuh=10;
inpCod.cod[3].xuh=15;
inpCod.cod[4].xuh=16;*/
return retflag;
}//inputCod()
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 292 2009-12-17 18:16 产生式系统 正向和反向\data.txt
文件 58 2009-12-13 21:24 产生式系统 正向和反向\goal.txt
文件 179 2009-12-17 18:16 产生式系统 正向和反向\rules.txt
文件 14355 2009-12-26 00:11 产生式系统 正向和反向\产生式系统 正向和反向 finnal.c
目录 0 2010-01-09 16:14 产生式系统 正向和反向
----------- --------- ---------- ----- ----
14884 5
- 上一篇:C语言windows库函数
- 下一篇:C++ AVI播放器
相关资源
- C语言开发实战宝典
- C++中头文件与源文件的作用详解
- 基于mfc的多线程文件传输
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- C语言代码高亮html输出工具
- 猜数字游戏 c语言代码
- C语言课程设计
- 数字电位器C语言程序
- CCS FFT c语言算法
- 使用C语言编写的病房管理系统
- 通信过程中的RS编译码程序(c语言)
- 利用C++哈希表的方法实现电话号码查
- 计算机二级C语言上机填空,改错,编
- 用回溯法解决八皇后问题C语言实现
- 移木块游戏,可以自编自玩,vc6.0编写
- 简易教务管理系统c语言开发文档
- 操作系统课设 读写者问题 c语言实现
- 小波变换算法 c语言版
- C流程图生成器,用C语言代码 生成C语
- 3des加密算法C语言实现
- 简单的C语言点对点聊天程序
- 单片机c语言源程序(51定时器 八个按
- C++纯文字DOS超小RPG游戏
- 个人日常财务管理系统(C语言)
- MFC数字钟(基于VC6.0)
- c语言电子商务系统
- 小甲鱼C语言课件 源代码
- 将图片转换为C语言数组的程序
- 安科瑞智能电能表MODBUS通讯程序 VC6
评论
共有 条评论