C语言程序设计教程电子教案之案例,里边有几百个c语言程序

源代码在线查看: 11-2.c

软件大小: 95 K
上传用户: captainjn
关键词: C语言程序 设计教程 电子教案 案例
下载地址: 免注册下载 普通下载 VIP

相关代码

				/*11-2.c*/
				#include 
				#include
				#include
				#include
				#define N 10
				#define M 11
				struct RL{
					  int rnum;
					  int rpsum;
					  char pre[N][5];
					  char res[5];
						 };
				struct RL zrul[N];
				char *pre[]={
							 "p1","p2","p3","p4","p5","p6","p7",
							 "p8","p9","p10","p11"
				};
				char *symptom[]={
								 "咳嗽","流鼻涕","怕冷","打喷嚏","痰多","体温高","血象偏高",
								 "泛酸","呕吐","上腹隐痛","食欲不振",
								 };
				char *result[]={
								 "r1","r2","r3"
				};
					 char *diagnose[]={
									   "上感","支气管炎","胃炎"
				};
				
				int  have()
				{
				 FILE *fp;
				 int i,ri=-1,rs=0;
				 char mstr[5];
				 char dstr[N][5];
				 if((fp=fopen("c:\\bc\\bin\\jingyan.txt","rt"))==NULL)
				   {
				   printf("Can not open flie");
				   exit(0);
				   }
				  while(fscanf(fp,"%s",mstr)!=EOF)
					{
					  if((!strstr(mstr,"p"))&&(!strstr(mstr,"r")))
						{
						ri++;
						 zrul[ri].rnum=atoi(mstr);
						if(ri>0)
							 {
							zrul[ri-1].rpsum=rs-1;
						for(i=0;i						  strcpy(zrul[ri-1].pre[i],dstr[i]);
							  strcpy(zrul[ri-1].res,dstr[rs-1]);
							  }
						  rs=0;
						}
					  else
						 {
						 strcpy(dstr[rs],mstr);
						 rs++;
						 }
					}
							zrul[ri].rpsum=rs-1;
						for(i=0;i						  strcpy(zrul[ri].pre[i],dstr[i]);
							  strcpy(zrul[ri].res,dstr[rs-1]);
				fclose(fp);
				return(ri+1);
				}
				query(int n)
				{
				  FILE *fp,*fpi;
				  char lstr[N][5];
				  char mstr[5];
				  int i=0,j=0,k=0;
				  int psum=0;
				  int agrees=0;
				  int m;
				  if((fp=fopen("c:\\bc\\bin\\pre.txt","rt"))==NULL)
				   {
				   printf("Can not open flie");
				   exit(0);
				   }
				   if((fpi=fopen("c:\\bc\\bin\\reason.txt","wt"))==NULL)
				   {
				   printf("Can not open flie");
				   exit(0);
				   }
				  while(fscanf(fp,"%s",mstr)!=EOF)
					{
					  strcpy(lstr[i],mstr);
					  i++;
					}
				   fclose(fp);
				   psum=i;
				  for(i=0;i					{
					 if(zrul[i].rpsum==psum)
						{
						 for(j=0;j							{
							 for(k=0;k							   {
								if(!strcmp(lstr[j],zrul[i].pre[k]))
									 agrees++;
							   }
							}
						if(agrees==zrul[i].rpsum)
							 fprintf(fpi,"%s ",zrul[i].res);
								agrees=0;
						for(m=0;m						 {
						 if(!strcmp(zrul[i].res,result[m]))
						printf("\n对你的症状做出的诊断为:%s\n",diagnose[m]);
						 }
						}
					}
					fclose(fpi);
				}
				main()
				 {
				 int n;
				  system("c:\\bc\\bin\\exper_1.exe");
				 n=have();
				   query(n);
				 }
							

相关资源