68.c
来自「上百个标准C语言的源代码」· C语言 代码 · 共 62 行
C
62 行
/*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[]={
"cough","snivel","cold-sensitive","sneezes","phlegm","high temperature","high hemogram",
"acidity","sick up","bellyache","inappetence",
};
main()
{
int i,j;
FILE *fp;
char answer;
char midpre[N][5];
if((fp=fopen("c:\\turboc2\\pre.txt","wt"))==NULL)
{
printf("Can not open file");
exit(0);
}
for(i=0;i<N;i++)
{
printf("\nDo you have a%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("\nYou diagnose is:you have a");
if((fp=fopen("c:\\turboc2\\pre.txt","rt"))==NULL)
{
printf("Can not open file");
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("\nPut any key to back\n");
getch();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?