⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 11-1.c

📁 《C语言程序设计实训》第十一章
💻 C
字号:
/*11-1.c*/
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#define N 11
char *pre[]={
			 "p1","p2","p3","p4","p5","p6","p7",
			 "p8","p9","p10","p11"
};
char *symptom[]={
				 "咳嗽","流鼻涕","怕冷","打喷嚏","痰多","体温高","血象偏高",
				 "泛酸","呕吐","上腹隐痛","食欲不振",
				 };
main()
{
int i,j;
FILE *fp;
char answer;
char midpre[N][5];
if((fp=fopen("c:\\bc\\bin\\pre.txt","wt"))==NULL)
   {
   printf("Can not open flie");
   exit(0);
   }

for(i=0;i<N;i++)
{
  printf("\n你%s吗?\n",symptom[i]);
  answer=strlwr(getch());
  switch(answer)
  {
  case 'y':
	 putchar(answer);
	fprintf(fp,"%s",pre[i]);
	fprintf(fp," ");
	break;
 case 'n':
   putchar(answer);
   break;
  }
}
fclose(fp);
printf("\n你的症状是:");
if((fp=fopen("c:\\bc\\bin\\pre.txt","rt"))==NULL)
   {
   printf("Can not open flie");
   exit(0);
   }
   i=0;
while(fscanf(fp,"%s",midpre[i])!=EOF)
  {
	for(j=0;j<N;j++)
	 {
	  if(!strcmp(midpre[i],pre[j]))
	  printf("%s ",symptom[j]);
	 }
  }
  fclose(fp);
printf("\n按任意键返回\n");
getch();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -