C语言实现医院诊疗管理系统

前言:这是我在大一时候做的C语言课程设计项目,当时用的IDE是VS2019,程序结构组织很简单(见下图),但那时候作为完完全全的小白还是费了不少劲的,后来还拿这个发了篇软著,现在把源码放出来给大家参考一下。

C语言实现医院诊疗管理系统_第1张图片

对于刚学编程的同学们,如果有此类课设任务,真心建议大家从头自己一点一点实现,而不是直接找学长要或者从网上down,可以去网上找源码参考,重点看它的实现思路,大体的思路有了,大家自己实现起来也就没那么难了。刚开始的时候总是很艰难的,怎么选择IDE、怎么调试、怎么理解需求,但一旦跨过去就是一片坦途了,那时你也将取得巨大的成长。

程序主界面如下:

C语言实现医院诊疗管理系统_第2张图片


1、base.h //本系统代码由多文件组织完成,以下用“序号+文件名”标识每个程序文件的代码

#pragma once
#include
#include
#include 
//诊疗记录 :患者信息、医生信息、诊疗情况 
//#define_CRT_SECURE_NO_WARNINGS
#pragma warning(disable:4996)
struct money {
	int yuan;
	int jiao;
	int fen;
};
struct patient{       //患者信息 
	int id;           //病人id  
	char name[20];
	int age; 
	struct patient *next;
}; 
struct doctor{        //医生信息 
	int id;           //工号  
	char name[20];
	int level;        //级别,有1-4级,分别对应住院医师、主治医师、副主任医师、主任医师
	int section;      //科室,共有1-6 六个科室
	int schedule[7];     //出诊时间 ,a[0]-a[6]分别对应周一到周日,不出诊为 0,出诊为 1 
	struct doctor *next;
};
struct cases{           //诊疗情况 
    int ifcheck;           //是否进行了检查 1是 0否 
	int ifprescribe;       //是否进行了开药 1是 0否    
	int ifinhospital;      //是否进行了住院  1是 0否    
    struct check{       //检查 
		struct money percost[200];  //每种检查费用 依次读入 此处可扩展 
		struct money totalcost;      //所有检查总费用 
	}check1;
	struct prescribe{   //开药 
		struct pill{       //药品信息 
			char pillname[20];  //药品名称 
			struct money price;           //单价 
			int count;           //药品数量 
		}piller[100];           //药品类对象 
		struct money totalcost;     //所有药品总费用 
	}prescribe1;
	struct inhospital {  //住院 
		int startdate[2];  //住院开始日期 
		int planoutdate[2];//预计出院日期 
		struct money cashin;             //住院押金 
	}inhospital1;      //第一个是字母l 第二个是数字1
};
struct record{   //诊疗记录
    char number[20];          // 挂号,8位 包含病人id两位,医生id两位,挂号月、日四位 为应对首位为0的情况所以用字符串实现
    int time[4]; //time[0]-time[3]分别对应月日时分 
	struct money cost;    //费用(该条诊疗记录的) ,需要输出的时候按两位小数输出,分别对应角分 
    struct patient pat;  //实例化命名规则:取前三个字母
	struct doctor  doc;  
    struct cases   cas;  
    struct record *next;
};
 
extern struct record * head;          //诊疗记录表头指针作为全局变量
struct record * add(struct record* p);                 //从文件中添加诊疗记录 
struct record* regist( struct record* p);               //挂号(即手动录入一条诊疗记录)
void search(void);                                       //查询模块
void output(struct record* p);                          //打印一个节点函数
void convert(struct money* a);                          //金额换算函数
struct record* modify(struct record* p);               //修改
struct record* delete1(struct record* p);               //删除
void save(void);                                        //保存到文件



2、regist.cpp
#include "base.h"
int createid(void) {      //生成患者id (值为当前患者最大id+1)
	int biggest = 0;
	struct record * now=head->next;
	biggest = now->pat.id;
	while (now != NULL) {
		if (now->pat.id > biggest) {
			biggest = now->pat.id;
		}
		now = now->next;
	}
	return biggest + 1; 
}
struct record* regist(struct record* p) {
	int i,m;  //i为循环控制变量 m用来读入后面键入的医生工号 
	struct record* x;
	x = (struct record*)malloc(sizeof(struct record));  //创建新节点
	p->next = x;
	p = p->next;
	x = NULL;
	p->next = NULL;
	int a;                
	p->cost.yuan = 0;              //消费金额初始化
	p->cost.jiao = 0;
	p->cost.fen= 0;
	p->cas.check1.totalcost.yuan = 0;    //检查费用
	p->cas.check1.totalcost.jiao = 0;
	p->cas.check1.totalcost.fen = 0;
	p->cas.prescribe1.totalcost.yuan = 0;  //开药费用
	p->cas.prescribe1.totalcost.jiao = 0;
	p->cas.prescribe1.totalcost.fen = 0;
	printf("\n********挂号功能********\n");
	printf("请问您是否已有id?1是0否\n");                //录入病人信息
	scanf("%d", &a);
	if (a==1) {
		printf("请输入您的id:\n");
		scanf("%d", &p->pat.id);
	}
	else {
		p->pat.id = createid();
		printf("已为您生成 您的id为%d\n", p->pat.id);
	}
	printf("请输入您的姓名:\n");
	scanf("%s", p->pat.name);
	printf("请输入您的年龄:\n");
	scanf("%d", &p->pat.age);
	printf("请按照月 日 时 分 间隔输入当前时间:\n");        //挂号时间
	for (i = 0; i < 4; i++) {
		scanf("%d", &p->time[i]);
	}
	printf("\n");
	printf("科室1——内科        科室2——外科          级别1——住院医师    级别2——主治医师 \n");          //挂号 选择医生
	printf("科室3——妇产科     科室4——儿科           级别3——副主任医师  级别4——主任医师 \n");
	printf("科室5——口腔科     科室6——耳鼻喉科       出诊日期用七位的0、1代表周一到周日 出诊为1 不出诊为0  \n");
	printf("\n");
	printf("科室   工号  姓名   级别   出诊日期\n");
	printf("1      10    王一    1     1 0 1 0 0 0 0\n");
	printf("1      11    王四    2     0 0 1 1 0 0 0\n");
	printf("1      12    王五    2     0 0 0 1 1 0 0\n");
	printf("1      13    赵二    4     0 1 1 0 0 0 1\n");
	printf("\n");
	printf("2       7    赵三    1     1 1 1 0 0 0 0\n");
	printf("2       9    王二    2     1 1 0 0 0 0 0\n");
	printf("2       8    赵五    2     1 0 1 0 0 0 0\n");
	printf("2       6    钱一    4     1 0 0 0 0 1 0\n");
	printf("\n");
	printf("3       3    钱二    1     1 1 0 1 0 0 0\n");
	printf("3       2    钱三    2     0 0 0 1 1 1 0\n");
	printf("3       4    钱五    3     1 1 0 0 0 0 0\n");
	printf("3       1    孙一    4     0 1 1 0 0 0 0\n");
	printf("\n");
	printf("4      16    孙二    1     1 1 1 0 0 0 0\n");
	printf("4      15    孙三    1     1 0 0 0 0 1 0\n");
	printf("4       5    孙五    2     1 1 1 0 0 0 0\n");
	printf("4      14    李一    4     0 0 0 0 1 0 1\n");
	printf("\n");
	printf("5      19    李二    1     0 0 0 1 1 1 0\n");
	printf("5      18    李三    1     0 0 0 1 0 1 0\n");
	printf("5      17    李五    3     0 1 1 1 0 0 0\n");
	printf("5      20    吴一    4     0 0 0 0 0 1 1\n");
	printf("\n");
	printf("6      23    吴二    1     0 0 0 1 1 1 1\n");
	printf("6      24    吴三    2     1 1 0 0 1 0 0\n");
	printf("6      21    吴四    3     0 0 0 1 1 0 0\n");
	printf("6      22    吴五    4     1 0 1 0 0 0 0\n");
	printf("\n");
	printf("请输入您选择挂号的医生工号:");
	scanf("%d", &m);
	printf("\n");
	switch (m) {
	case 1:
		p->doc.id=m;
		strcpy(p->doc.name, "孙一");
		p->doc.level = 4;
		p->doc.section = 3;
		p->doc.schedule[0] = 0;
		p->doc.schedule[1] = 1;
		p->doc.schedule[2] = 1;
		p->doc.schedule[3] = 0;
		p->doc.schedule[4] = 0;
		p->doc.schedule[5] = 0;
		p->doc.schedule[6] = 0;
		break;
	case 2:
		p->doc.id = m;
		strcpy(p->doc.name, "钱三");
		p->doc.level = 2;
		p->doc.section = 3;
		p->doc.schedule[0] = 0;
		p->doc.schedule[1] = 0;
		p->doc.schedule[2] = 0;
		p->doc.schedule[3] = 1;
		p->doc.schedule[4] = 1;
		p->doc.schedule[5] = 1;
		p->doc.schedule[6] = 0;
		break;
	case 3:
		p->doc.id = m;
		strcpy(p->doc.name, "钱二");
		p->doc.level = 1;
		p->doc.section = 3;
		p->doc.schedule[0] = 1;
		p->doc.schedule[1] = 1;
		p->doc.schedule[2] = 0;
		p->doc.schedule[3] = 1;
		p->doc.schedule[4] = 0;
		p->doc.schedule[5] = 0;
		p->doc.schedule[6] = 0;
		break;
	case 4:
		p->doc.id = m;
		strcpy(p->doc.name, "钱五");
		p->doc.level = 3;
		p->doc.section = 3;
		p->doc.schedule[0] = 1;
		p->doc.schedule[1] = 1;
		p->doc.schedule[2] = 0;
		p->doc.schedule[3] = 0;
		p->doc.schedule[4] = 0;
		p->doc.schedule[5] = 0;
		p->doc.schedule[6] = 0;
		break;
	case 5:
		p->doc.id = m;
		strcpy(p->doc.name, "孙五");
		p->doc.level = 2;
		p->doc.section = 4;
		p->doc.schedule[0] = 1;
		p->doc.schedule[1] = 1;
		p->doc.schedule[2] = 1;
		p->doc.schedule[3] = 0;
		p->doc.schedule[4] = 0;
		p->doc.schedule[5] = 0;
		p->doc.schedule[6] = 0;
		break;
	case 6:
		p->doc.id = m;
		strcpy(p->doc.name, "钱一");
		p->doc.level = 4;
		p->doc.section = 2;
		p->doc.schedule[0] = 1;
		p->doc.schedule[1] = 0;
		p->doc.schedule[2] = 0;
		p->doc.schedule[3] = 0;
		p->doc.schedule[4] = 0;
		p->doc.schedule[5] = 1;
		p->doc.schedule[6] = 0;
		break;
	case 7:
		p->doc.id = m;
		strcpy(p->doc.name, "赵三");
		p->doc.level = 1;
		p->doc.section = 2;
		p->doc.schedule[0] = 1;
		p->doc.schedule[1] = 1;
		p->doc.schedule[2] = 1;
		p->doc.schedule[3] = 0;
		p->doc.schedule[4] = 0;
		p->doc.schedule[5] = 0;
		p->doc.schedule[6] = 0;
		break;
	case 8:
		p->doc.id = m;
		strcpy(p->doc.name, "赵五");
		p->doc.level = 2;
		p->doc.section = 2;
		p->doc.schedule[0] = 1;
		p->doc.schedule[1] = 0;
		p->doc.schedule[2] = 1;
		p->doc.schedule[3] = 0;
		p->doc.schedule[4] = 0;
		p->doc.schedule[5] = 0;
		p->doc.schedule[6] = 0;
		break;
	case 9:
		p->doc.id = m;
		strcpy(p->doc.name, "王二");
		p->doc.level = 2;
		p->doc.section = 2;
		p->doc.schedule[0] = 1;
		p->doc.schedule[1] = 1;
		p->doc.schedule[2] = 0;
		p->doc.schedule[3] = 0;
		p->doc.schedule[4] = 0;
		p->doc.schedule[5] = 0;
		p->doc.schedule[6] = 0;
		break;
	case 10:
		p->doc.id = m;
		strcpy(p->doc.name, "王一");
		p->doc.level = 1;
		p->doc.section = 1;
		p->doc.schedule[0] = 1;
		p->doc.schedule[1] = 0;
		p->doc.schedule[2] = 1;
		p->doc.schedule[3] = 0;
		p->doc.schedule[4] = 0;
		p->doc.schedule[5] = 0;
		p->doc.schedule[6] = 0;
		break;
	case 11:
		p->doc.id = m;
		strcpy(p->doc.name, "王四");
		p->doc.level = 2;
		p->doc.section = 1;
		p->doc.schedule[0] = 0;
		p->doc.schedule[1] = 0;
		p->doc.schedule[2] = 1;
		p->doc.schedule[3] = 1;
		p->doc.schedule[4] = 0;
		p->doc.schedule[5] = 0;
		p->doc.schedule[6] = 0;
		break;
	case 12:
		p->doc.id = m;
		strcpy(p->doc.name, "王五");
		p->doc.level = 2;
		p->doc.section = 1;
		p->doc.schedule[0] = 0;
		p->doc.schedule[1] = 0;
		p->doc.schedule[2] = 0;
		p->doc.schedule[3] = 1;
		p->doc.schedule[4] = 1;
		p->doc.schedule[5] = 0;
		p->doc.schedule[6] = 0;
		break;
	case 13:
		p->doc.id = m;
		strcpy(p->doc.name, "赵二");
		p->doc.level = 4;
		p->doc.section = 1;
		p->doc.schedule[0] = 0;
		p->doc.schedule[1] = 1;
		p->doc.schedule[2] = 1;
		p->doc.schedule[3] = 0;
		p->doc.schedule[4] = 0;
		p->doc.schedule[5] = 0;
		p->doc.schedule[6] = 1;
		break;
	case 14:
		p->doc.id = m;
		strcpy(p->doc.name, "李一");
		p->doc.level = 4;
		p->doc.section = 4;
		p->doc.schedule[0] = 0;
		p->doc.schedule[1] = 0;
		p->doc.schedule[2] = 0;
		p->doc.schedule[3] = 0;
		p->doc.schedule[4] = 1;
		p->doc.schedule[5] = 0;
		p->doc.schedule[6] = 1;
		break;
	case 15:
		p->doc.id = m;
		strcpy(p->doc.name, "孙三");
		p->doc.level = 1;
		p->doc.section = 4;
		p->doc.schedule[0] = 1;
		p->doc.schedule[1] = 0;
		p->doc.schedule[2] = 0;
		p->doc.schedule[3] = 0;
		p->doc.schedule[4] = 0;
		p->doc.schedule[5] = 1;
		p->doc.schedule[6] = 0;
		break;
	case 16:
		p->doc.id = m;
		strcpy(p->doc.name, "孙二");
		p->doc.level = 1;
		p->doc.section = 4;
		p->doc.schedule[0] = 1;
		p->doc.schedule[1] = 1;
		p->doc.schedule[2] = 1;
		p->doc.schedule[3] = 0;
		p->doc.schedule[4] = 0;
		p->doc.schedule[5] = 0;
		p->doc.schedule[6] = 0;
		break;
	case 17:
		p->doc.id = m;
		strcpy(p->doc.name, "李五");
		p->doc.level = 3;
		p->doc.section = 5;
		p->doc.schedule[0] = 0;
		p->doc.schedule[1] = 1;
		p->doc.schedule[2] = 1;
		p->doc.schedule[3] = 1;
		p->doc.schedule[4] = 0;
		p->doc.schedule[5] = 0;
		p->doc.schedule[6] = 0;
		break;
	case 18:
		p->doc.id = m;
		strcpy(p->doc.name, "李三");
		p->doc.level = 1;
		p->doc.section = 5;
		p->doc.schedule[0] = 0;
		p->doc.schedule[1] = 0;
		p->doc.schedule[2] = 0;
		p->doc.schedule[3] = 1;
		p->doc.schedule[4] = 0;
		p->doc.schedule[5] = 1;
		p->doc.schedule[6] = 0;
		break;
	case 19:
		p->doc.id = m;
		strcpy(p->doc.name, "李二");
		p->doc.level = 1;
		p->doc.section = 5;
		p->doc.schedule[0] = 0;
		p->doc.schedule[1] = 0;
		p->doc.schedule[2] = 0;
		p->doc.schedule[3] = 1;
		p->doc.schedule[4] = 1;
		p->doc.schedule[5] = 1;
		p->doc.schedule[6] = 0;
		break;
	case 20:
		p->doc.id = m;
		strcpy(p->doc.name, "吴一");
		p->doc.level = 4;
		p->doc.section = 5;
		p->doc.schedule[0] = 0;
		p->doc.schedule[1] = 0;
		p->doc.schedule[2] = 0;
		p->doc.schedule[3] = 0;
		p->doc.schedule[4] = 0;
		p->doc.schedule[5] = 1;
		p->doc.schedule[6] = 1;
		break;
	case 21:
		p->doc.id = m;
		strcpy(p->doc.name, "吴四");
		p->doc.level = 3;
		p->doc.section = 6;
		p->doc.schedule[0] = 0;
		p->doc.schedule[1] = 0;
		p->doc.schedule[2] = 0;
		p->doc.schedule[3] = 1;
		p->doc.schedule[4] = 1;
		p->doc.schedule[5] = 0;
		p->doc.schedule[6] = 0;
		break;
	case 22:
		p->doc.id = m;
		strcpy(p->doc.name, "吴五");
		p->doc.level = 4;
		p->doc.section = 6;
		p->doc.schedule[0] = 1;
		p->doc.schedule[1] = 0;
		p->doc.schedule[2] = 1;
		p->doc.schedule[3] = 0;
		p->doc.schedule[4] = 0;
		p->doc.schedule[5] = 0;
		p->doc.schedule[6] = 0;
		break;
	case 23:
		p->doc.id = m;
		strcpy(p->doc.name, "吴二");
		p->doc.level = 1;
		p->doc.section = 6;
		p->doc.schedule[0] = 0;
		p->doc.schedule[1] = 0;
		p->doc.schedule[2] = 0;
		p->doc.schedule[3] = 1;
		p->doc.schedule[4] = 1;
		p->doc.schedule[5] = 1;
		p->doc.schedule[6] = 1;
		break;
	case 24:
		p->doc.id = m;
		strcpy(p->doc.name, "吴三");
		p->doc.level = 2;
		p->doc.section = 6;
		p->doc.schedule[0] = 1;
		p->doc.schedule[1] = 1;
		p->doc.schedule[2] = 0;
		p->doc.schedule[3] = 0;
		p->doc.schedule[4] = 1;
		p->doc.schedule[5] = 0;
		p->doc.schedule[6] = 0;
		break;
	}
	printf("\n");
	printf("请问您是否需要进行检查:输入0为否 输入1为是  ");
	scanf("%d", &p->cas.ifcheck);
	if (p->cas.ifcheck != 0 && p->cas.ifcheck != 1) {
		printf("\n输入有误 请重新输入!\n");
		scanf("%d", &p->cas.ifcheck);
	}
	int flag,count=0;
	if (p->cas.ifcheck==1) {
		i = 0;
		while (1) {
			printf("1.血常规 30元\n");
			printf("2.尿常规 40元\n");
			printf("3.测血糖 10元\n");
			printf("4.CT 300元\n");
			printf("5.彩超 200元\n");
			printf("0.退出\n");
			scanf("%d", &flag);
			switch (flag) {
			case 1:
				p->cas.check1.percost[i].yuan = 30;
				p->cas.check1.percost[i].jiao= 0;
				p->cas.check1.percost[i].fen = 0;
				p->cas.check1.totalcost.yuan += p->cas.check1.percost[i].yuan;
				i++;
				break;
			case 2:
				p->cas.check1.percost[i].yuan = 40;
				p->cas.check1.percost[i].jiao = 0;
				p->cas.check1.percost[i].fen = 0;
				p->cas.check1.totalcost.yuan += p->cas.check1.percost[i].yuan;
				i++;
				break;
			case 3:
				p->cas.check1.percost[i].yuan = 10;
				p->cas.check1.percost[i].jiao = 0;
				p->cas.check1.percost[i].fen = 0;
				p->cas.check1.totalcost.yuan += p->cas.check1.percost[i].yuan;
				i++;
				break;
			case 4:
				p->cas.check1.percost[i].yuan = 300;
				p->cas.check1.percost[i].jiao = 0;
				p->cas.check1.percost[i].fen = 0;
				p->cas.check1.totalcost.yuan += p->cas.check1.percost[i].yuan;
				i++;
				break;
			case 5:
				p->cas.check1.percost[i].yuan = 200;
				p->cas.check1.percost[i].jiao = 0;
				p->cas.check1.percost[i].fen = 0;
				p->cas.check1.totalcost.yuan += p->cas.check1.percost[i].yuan;
				i++;
				break;
			case 0:
				p->cas.check1.percost[i].yuan = -1;
				break;
			default:
				printf("输入有误 请重新输入:\n");
				continue;
			}
		    convert(&(p->cas.check1.totalcost));
			if (flag == 0)
				break;
		}
	}
	printf("\n");
	printf("请问您是否需要进行开药:输入0为否 输入1为是  ");
	scanf("%d", &p->cas.ifprescribe);
	if (p->cas.ifprescribe != 0 && p->cas.ifprescribe != 1) {
		printf("\n输入有误 请重新输入!\n");
		scanf("%d", &p->cas.ifprescribe);
	}
	if (p->cas.ifprescribe==1) {
		i = 0;
		while (1) {
			printf("1.感康 18元\n");
			printf("2.金银花颗粒 20元\n");
			printf("3.枇杷露 12元\n");
			printf("4.金嗓子喉宝 13元\n");
			printf("0.退出\n");
			scanf("%d", &flag);
			switch (flag) {
			case 1:
				printf("购买数量:\n");
				scanf("%d", &count);
				strcpy(p->cas.prescribe1.piller[i].pillname, "感康");
				p->cas.prescribe1.piller[i].price.yuan = 18;
				p->cas.prescribe1.piller[i].price.jiao = 0;
				p->cas.prescribe1.piller[i].price.fen = 0;
				p->cas.prescribe1.piller[i].count = count;
				p->cas.prescribe1.totalcost.yuan += count * 18;
				i++;
				break;
			case 2:
				printf("购买数量:\n");
				scanf("%d", &count);
				strcpy(p->cas.prescribe1.piller[i].pillname, "金银花颗粒");
				p->cas.prescribe1.piller[i].price.yuan = 20;
				p->cas.prescribe1.piller[i].price.jiao = 0;
				p->cas.prescribe1.piller[i].price.fen = 0;
				p->cas.prescribe1.piller[i].count = count;
				p->cas.prescribe1.totalcost.yuan += count * 20;
				i++;
				break;
			case 3:
				printf("购买数量:\n");
				scanf("%d", &count);
				strcpy(p->cas.prescribe1.piller[i].pillname, "枇杷露");
				p->cas.prescribe1.piller[i].price.yuan = 12;
				p->cas.prescribe1.piller[i].price.jiao = 0;
				p->cas.prescribe1.piller[i].price.fen = 0;
				p->cas.prescribe1.piller[i].count = count;
				p->cas.prescribe1.totalcost.yuan += count * 12;
				i++;
				break;
			case 4:
				printf("购买数量:\n");
				scanf("%d", &count);
				strcpy(p->cas.prescribe1.piller[i].pillname, "金嗓子喉宝");
				p->cas.prescribe1.piller[i].price.yuan = 13;
				p->cas.prescribe1.piller[i].price.jiao = 0;
				p->cas.prescribe1.piller[i].price.fen = 0;
				p->cas.prescribe1.piller[i].count = count;
				p->cas.prescribe1.totalcost.yuan += count * 13;
				i++;
				break;
			case 0:
				strcpy(p->cas.prescribe1.piller[i].pillname, "over");
				break;
			default:
				printf("输入有误 请重新输入:\n");
				continue;
			}
			convert(&(p->cas.prescribe1.totalcost));
			if (flag == 0)
				break;
		}
	}
	printf("\n");
	printf("请问您是否需要进行住院:输入0为否 输入1为是  ");
	scanf("%d", &p->cas.ifinhospital);
	if (p->cas.ifinhospital != 0 && p->cas.ifinhospital != 1) {
		printf("\n输入有误 请重新输入!\n");
		scanf("%d", &p->cas.ifinhospital);
	}
	if (p->cas.ifinhospital==1) {
		printf("请输入住院开始月、日:\n");
		scanf("%d %d", &p->cas.inhospital1.startdate[0], &p->cas.inhospital1.startdate[1]);
		printf("请输入预计出院月、日:\n");
		scanf("%d %d", &p->cas.inhospital1.planoutdate[0], &p->cas.inhospital1.planoutdate[1]);
		printf("请按元 角 分 依次输入您的住院押金金额 至少为1000元\n");
		scanf("%d", &p->cas.inhospital1.cashin.yuan);
		scanf("%d", &p->cas.inhospital1.cashin.jiao);
		scanf("%d", &p->cas.inhospital1.cashin.fen);
		if (p->cas.inhospital1.cashin.yuan < 1000) {
			printf("输入有误 请重新输入!\n");
			printf("请按元 角 分 依次输入您的住院押金金额 至少为1000元\n");
			scanf("%d", &p->cas.inhospital1.cashin.yuan);
			scanf("%d", &p->cas.inhospital1.cashin.jiao);
			scanf("%d", &p->cas.inhospital1.cashin.fen);
		}
		convert(&(p->cas.inhospital1.cashin));
	}
	//生成挂号
	char j[100], k[100];
	if (p->pat.id <= 9) {                  //处理患者id首位为0的情况
		sprintf(j, "%d", p->pat.id);          //把整型转换成字符串
		p->number[0] = '0';
		p->number[1] = '\0';
		strcat(p->number, j);                //字符串拼接
	}
	else {
		sprintf(p->number, "%d", p->pat.id);
	}
	if (p->doc.id <= 9) {
		sprintf(k, "%d", p->doc.id);
		p->number[2] = '0';
		p->number[3] = '\0';
		strcat(p->number, k);
	}
	else {
		sprintf(k, "%d", p->doc.id);
		strcat(p->number, k);
	}
	if (p->time[0] > 9) {                //月为两位
		sprintf(j, "%d", p->time[0]);
		strcat(p->number, j);
	}
	else {                               //月为一位
		p->number[4] = '0';
		p->number[5] = '\0';
		sprintf(j, "%d", p->time[0]);
		strcat(p->number, j);
	}
	if (p->time[1] > 9) {               //日为两位
		sprintf(j, "%d", p->time[1]);
		strcat(p->number, j);
	}
	else {                               //日为一位
		p->number[6] = '0';
		p->number[7] = '\0';
		sprintf(j, "%d", p->time[1]);
		strcat(p->number, j);
	}
	printf("\n");
	printf("您已成功挂号! 您的挂号为%s\n", p->number);
	p->cost.yuan = p->cas.check1.totalcost.yuan + p->cas.prescribe1.totalcost.yuan;   //统计消费金额
	p->cost.jiao = p->cas.check1.totalcost.jiao + p->cas.prescribe1.totalcost.jiao;
	p->cost.fen = p->cas.check1.totalcost.fen + p->cas.prescribe1.totalcost.fen;
	convert(&(p->cost));
	printf("\n");
	return p;
}




3、add.cpp
#include "base.h"

void convert(struct money *a) {   //金额换算函数
	a->jiao += a->fen / 10;
	a->fen = a->fen % 10;
	a->yuan += a->jiao / 10;
	a->jiao = a->jiao % 10;
	return ;
}

struct record * add(struct record* p) {               //add函数实现的是在所给节点指针后链接n个新节点
	FILE* fp;
	int n, i = 0, j;                //n为录入诊疗记录的条数,i ,j是循环控制变量
	if ((fp = fopen("test.txt", "r"))==NULL) {
		printf("Fail to open the file!\n");
		return NULL;
	}
	struct record * x;   //x用于创建链表新节点
	printf("\n********录入功能********\n");
	printf("请输入您想录入诊疗记录的条数:  ");
	scanf("%d", &n);
	printf("\n");    //下次输出另起一行

	if (n <= 0||n>30) {
		printf("输入不合法!\n");
		return NULL;
	}
	while (i < n) {      //录入n条诊疗记录
		if (feof(fp)) {
			printf("已经到达文件尾部\n");
			return NULL;
		}
		x = (struct record*)malloc(sizeof(struct record));
		p->next = x;
		p = p->next;
		x = NULL;
		p->next = NULL;
		fscanf(fp, "%s", &p->number);  //读入挂号
		for (j = 0; j < 4; j++)        //读入时间
			fscanf(fp, "%d", &p->time[j]);
		p->cost.yuan = 0;         //该条诊疗记录的费用初始化为0
		p->cost.jiao = 0;
		p->cost.fen = 0;
		p->cas.check1.totalcost.yuan = 0;    //检查费用初始化为0
		p->cas.check1.totalcost.jiao = 0;
		p->cas.check1.totalcost.fen = 0;
		p->cas.prescribe1.totalcost.yuan = 0;  //开药费用初始化为0
		p->cas.prescribe1.totalcost.jiao = 0;
		p->cas.prescribe1.totalcost.fen = 0;
		fscanf(fp, "%d", &p->pat.id);    //病人信息
		fscanf(fp, "%s", p->pat.name);
		fscanf(fp, "%d", &p->pat.age);

		fscanf(fp, "%d", &p->doc.id);    //医生信息
		fscanf(fp, "%s", p->doc.name);
		fscanf(fp, "%d", &p->doc.level);
		fscanf(fp, "%d", &p->doc.section);
		for (j = 0; j < 7; j++) {
			fscanf(fp, "%d", &p->doc.schedule[j]);     //用一个长度为7的数组来保存医生的出诊时间,
		}

		fscanf(fp, "%d", &p->cas.ifcheck);   //诊疗情况
		fscanf(fp, "%d", &p->cas.ifprescribe);
		fscanf(fp, "%d", &p->cas.ifinhospital);
		j = 0;
		if (p->cas.ifcheck == 1) {         //如果进行了检查 则进入下层统计费用 否则什么也不执行 检查总费用为0
			fscanf(fp, "%d", &p->cas.check1.percost[j].yuan); //先读入一个然后进入循环 
			while (p->cas.check1.percost[j].yuan != -1) {     //约定输入元为-1时结束
				fscanf(fp, "%d", &p->cas.check1.percost[j].jiao);
				fscanf(fp, "%d", &p->cas.check1.percost[j].fen);
				p->cas.check1.totalcost.yuan += p->cas.check1.percost[j].yuan;  //下三行即是将单项检查费用统计到总费用中 此时角分均可大于10
				p->cas.check1.totalcost.jiao += p->cas.check1.percost[j].jiao;
				p->cas.check1.totalcost.fen += p->cas.check1.percost[j].fen;
				j++;
				fscanf(fp, "%d", &p->cas.check1.percost[j].yuan);               //最后这个-1还是读进来了 存到了最后一项检查费用的后面
			}
			convert(&(p->cas.check1.totalcost));    //把金额换算成十进制 按地址传送
		}              //检查录入完毕
		if (p->cas.ifprescribe == 1) {
			fscanf(fp, "%s", p->cas.prescribe1.piller[0].pillname);
			j = 0;
			while (strcmp(p->cas.prescribe1.piller[j].pillname, "over") != 0) {   //读入所开药品的信息 约定药品名为over时为结束 
				fscanf(fp, "%d", &p->cas.prescribe1.piller[j].price.yuan);  //一种药的单价
				fscanf(fp, "%d", &p->cas.prescribe1.piller[j].price.jiao);
				fscanf(fp, "%d", &p->cas.prescribe1.piller[j].price.fen);
				fscanf(fp, "%d", &p->cas.prescribe1.piller[j].count);      //药品数
				p->cas.prescribe1.totalcost.yuan += p->cas.prescribe1.piller[j].count * p->cas.prescribe1.piller[j].price.yuan;  //统计开药总费用,此时角分都可能大于10
				p->cas.prescribe1.totalcost.jiao += p->cas.prescribe1.piller[j].count * p->cas.prescribe1.piller[j].price.jiao;
				p->cas.prescribe1.totalcost.fen += p->cas.prescribe1.piller[j].count * p->cas.prescribe1.piller[j].price.fen;
				j++;
				fscanf(fp, "%s", p->cas.prescribe1.piller[j].pillname);
			}
			convert(&(p->cas.prescribe1.totalcost)); //把金额换算成十进制 按地址传送
		}             //开药录入完毕

		if (p->cas.ifinhospital == 1) {
			fscanf(fp, "%d", &p->cas.inhospital1.startdate[0]);   //读入住院日期 月 日
			fscanf(fp, "%d", &p->cas.inhospital1.startdate[1]);
			fscanf(fp, "%d", &p->cas.inhospital1.planoutdate[0]);  //读入预计出院日期 月 日
			fscanf(fp, "%d", &p->cas.inhospital1.planoutdate[1]);
			fscanf(fp, "%d", &p->cas.inhospital1.cashin.yuan);     //读入押金
			fscanf(fp, "%d", &p->cas.inhospital1.cashin.jiao);
			fscanf(fp, "%d", &p->cas.inhospital1.cashin.fen);
			convert(&(p->cas.inhospital1.cashin));        //处理输入金额不规范的情况
			if (p->cas.inhospital1.cashin.yuan < 1000) {
				printf("请挂号为%s的患者缴纳住院押金,您的押金已不足\n", p->number);
			}
		}
		i++;                                     //循环控制变量+1   读入诊疗记录数量+1
		p->cost.yuan = p->cas.check1.totalcost.yuan + p->cas.prescribe1.totalcost.yuan;
		p->cost.jiao = p->cas.check1.totalcost.jiao + p->cas.prescribe1.totalcost.jiao;
		p->cost.fen = p->cas.check1.totalcost.fen + p->cas.prescribe1.totalcost.fen;
		convert(&(p->cost));
	};
	printf("%d条诊疗记录已录入完毕。\n", n);
	printf("\n");
	fclose(fp);   
	return p;
}




4、save.cpp
#include "base.h"
void save(void) {
	FILE* fp;
	fp = fopen("storage.txt", "w");
	if (fp == NULL) {
		printf("打开文件失败!返回上层\n");
		return;
	}
	struct record* p = head->next;
	while (p != NULL) {
		int i;
		fprintf(fp,"挂号:%s\n", p->number);
		fprintf(fp, "时间:%d月 %d日 %d时 %d分\n", p->time[0], p->time[1], p->time[2], p->time[3]);
		fprintf(fp, "费用:%d元 %d角 %d分\n", p->cost.yuan, p->cost.jiao, p->cost.fen);
		fprintf(fp, "患者 ID:%d 姓名:%s 年龄:%d\n", p->pat.id, p->pat.name, p->pat.age);
		fprintf(fp, "医生 工号:%d 姓名:%s 级别:%d 科室:%d \n     出诊时间:", p->doc.id, p->doc.name, p->doc.level, p->doc.section);
		if (p->doc.schedule[0] == 1)                          //打印医生出诊时间
			fprintf(fp, " 周一");
		if (p->doc.schedule[1] == 1)
			fprintf(fp, " 周二");
		if (p->doc.schedule[2] == 1)
			fprintf(fp, " 周三");
		if (p->doc.schedule[3] == 1)
			fprintf(fp, " 周四");
		if (p->doc.schedule[4] == 1)
			fprintf(fp, " 周五");
		if (p->doc.schedule[5] == 1)
			fprintf(fp, " 周六");
		if (p->doc.schedule[6] == 1)
			fprintf(fp, " 周日");
		fprintf(fp, "\n\n");
		fprintf(fp, "诊疗情况:\n\n");
		if (p->cas.ifcheck == 1) {
			fprintf(fp, "进行了检查\n");
			i = 0;
			fprintf(fp, "各项检查费用分别为:");
			while (p->cas.check1.percost[i].yuan != -1) {
				fprintf(fp, "%d元 %d角 %d分  ", p->cas.check1.percost[i].yuan, p->cas.check1.percost[i].jiao, p->cas.check1.percost[i].fen);
				i++;
			}
			fprintf(fp, "\n");
			fprintf(fp, "所有检查总费用为:%d元 %d角 %d分\n", p->cas.check1.totalcost.yuan, p->cas.check1.totalcost.jiao, p->cas.check1.totalcost.fen);
		}
		if (p->cas.ifprescribe == 1) {
			fprintf(fp, "进行了开药\n");
			i = 0;
			while (strcmp(p->cas.prescribe1.piller[i].pillname, "over") != 0) {
				fprintf(fp, "药品名:%s  ", p->cas.prescribe1.piller[i].pillname);
				fprintf(fp, "单价:%d元 %d角 %d分  ", p->cas.prescribe1.piller[i].price.yuan, p->cas.prescribe1.piller[i].price.jiao, p->cas.prescribe1.piller[i].price.fen);
				fprintf(fp, "数量:%d\n", p->cas.prescribe1.piller[i].count);
				i++;
			}
			fprintf(fp, "所有药品总价:%d元 %d角 %d分\n", p->cas.prescribe1.totalcost.yuan, p->cas.prescribe1.totalcost.jiao, p->cas.prescribe1.totalcost.fen);

		}
		if (p->cas.ifinhospital == 1) {
			fprintf(fp, "进行了住院\n");
			fprintf(fp, "住院开始日期:%d月 %d日\n", p->cas.inhospital1.startdate[0], p->cas.inhospital1.startdate[1]);
			fprintf(fp, "预计出院日期:%d月 %d日\n", p->cas.inhospital1.planoutdate[0], p->cas.inhospital1.planoutdate[1]);
			fprintf(fp, "住院押金:%d元 %d角 %d分\n", p->cas.inhospital1.cashin.yuan, p->cas.inhospital1.cashin.jiao, p->cas.inhospital1.cashin.fen);
		}
		fprintf(fp,"\n\n");
		p = p->next;
	}
	printf("\n当前系统内所有信息已保存到文件storage.txt中\n");
	fclose(fp);
}

     

5、search.cpp
#include "base.h"
void output(struct record* p) {
	int i;
	printf("患者 ID:%d 姓名:%s 年龄:%d\n", p->pat.id, p->pat.name, p->pat.age);
	printf("挂号:%s\n",p->number);
	printf("时间:%d月 %d日 %d时 %d分\n",p->time[0], p->time[1], p->time[2], p->time[3]);
	printf("费用:%d元 %d角 %d分\n",p->cost.yuan,p->cost.jiao,p->cost.fen);
	printf("医生 工号:%d 姓名:%s 级别:%d 科室:%d \n     出诊时间:",p->doc.id,p->doc.name,p->doc.level,p->doc.section);
	if (p->doc.schedule[0] == 1)                          //打印医生出诊时间
		printf(" 周一");
	if (p->doc.schedule[1] == 1)
		printf(" 周二");
	if (p->doc.schedule[2] == 1)
		printf(" 周三");
	if (p->doc.schedule[3] == 1)
		printf(" 周四");
	if (p->doc.schedule[4] == 1)
		printf(" 周五");
	if (p->doc.schedule[5] == 1)
		printf(" 周六");
	if (p->doc.schedule[6] == 1)
		printf(" 周日");
	printf("\n\n");
	printf("诊疗情况:\n\n");
	if (p->cas.ifcheck == 1) {
		printf("进行了检查\n");
		i = 0;
		printf("各项检查费用分别为:");
		while (p->cas.check1.percost[i].yuan != -1) {
			printf("%d元 %d角 %d分  ", p->cas.check1.percost[i].yuan, p->cas.check1.percost[i].jiao, p->cas.check1.percost[i].fen);
			i++;
		}
		printf("\n");
		printf("所有检查总费用为:%d元 %d角 %d分\n", p->cas.check1.totalcost.yuan, p->cas.check1.totalcost.jiao, p->cas.check1.totalcost.fen);
	}
	if (p->cas.ifprescribe == 1) {
		printf("进行了开药\n");
		i = 0;
		while (strcmp(p->cas.prescribe1.piller[i].pillname, "over") != 0) {
			printf("药品名:%s  ", p->cas.prescribe1.piller[i].pillname);
			printf("单价:%d元 %d角 %d分  ", p->cas.prescribe1.piller[i].price.yuan, p->cas.prescribe1.piller[i].price.jiao, p->cas.prescribe1.piller[i].price.fen);
			printf("数量:%d\n", p->cas.prescribe1.piller[i].count);
			i++;
		}
		printf("所有药品总价:%d元 %d角 %d分\n", p->cas.prescribe1.totalcost.yuan, p->cas.prescribe1.totalcost.jiao, p->cas.prescribe1.totalcost.fen);

	}
	if (p->cas.ifinhospital == 1) {
		printf("进行了住院\n");
		printf("住院开始日期:%d月 %d日\n", p->cas.inhospital1.startdate[0], p->cas.inhospital1.startdate[1]);
		printf("预计出院日期:%d月 %d日\n", p->cas.inhospital1.planoutdate[0], p->cas.inhospital1.planoutdate[1]);
		printf("住院押金:%d元 %d角 %d分\n", p->cas.inhospital1.cashin.yuan, p->cas.inhospital1.cashin.jiao, p->cas.inhospital1.cashin.fen);
	}
	printf("\n\n");
}

void search(void) {                                //查询模块
	int x,a,b,m,n,flag=0;
	struct money sum;                         //营业额初始化为0
	sum.yuan = 0;
	sum.jiao = 0;
	sum.fen = 0;
	struct record* p=head->next;
	while (1) {
		sum.yuan = 0;
		sum.jiao = 0;
		sum.fen = 0;
		printf("\n********查询功能********\n");
		printf("1.查询所有诊疗记录\n");
		printf("2.查询某段时间范围内的诊疗记录\n");
		printf("3.查询某医生的诊疗信息\n");
		printf("4.查询某科室的诊疗信息\n");
		printf("5.查询某患者的诊疗信息\n");
		printf("6.当前医院的营业额\n");
		printf("7.每位医生的出诊情况和工作繁忙程度\n");
		printf("8.当前住院患者报表\n");
		printf("0.退出\n");
		printf("请输入:\n");
		scanf("%d",&x );
		printf("\n");
		switch (x) {
		case 0:
			return;
		case 1:
			p = head->next;
			while (p != NULL) {
				output(p);
				p = p->next;
			}
			printf("\n查询完毕\n");
			break;
		case 2:
			printf("请输入起始月份、终止月份:\n");
			scanf("%d%d", &a, &b);
			if (a > b) {
				printf("输入有误!请重新输入:\n");
				scanf("%d%d", &a, &b);
			}
			p = head->next;
			while (p != NULL) {
				if (p->time[0] >= a && p->time[0] <= b) {
					output(p);
				}
				p = p->next;
			}
			printf("\n查询完毕\n");
			break;
		case 3:
			printf("请输入该医生工号:");
			scanf("%d", &m);
			p = head->next;
			while (p != NULL) {
				if (m == p->doc.id) {
					flag = 1;
					output(p);
				}
				p = p->next;
			}
			if (flag == 0) 
				printf("\n不存在该医生的诊疗记录!\n");
			printf("\n查询完毕\n");
			break;
		case 4:
			printf("请输入查询的科室号:\n");
			scanf("%d", &n);
			if (n <= 0 || n > 6) {
				printf("输入有误!请重新输入:\n");
				scanf("%d", &n);
			}
			p = head->next;
			while (p != NULL) {
				if (p->doc.section == n) {
					output(p);
				}
				p = p->next;
			}
			printf("\n查询完毕\n");
			break;
		case 5:
			printf("请输入该患者ID:");
			scanf("%d", &m);
			p = head->next;
			while (p != NULL) {
				if (m == p->pat.id) {
					flag = 1;
					output(p);
				}
				p = p->next;
			}
			if (flag == 0)
				printf("\n不存在该患者的诊疗记录!\n");
			printf("\n查询完毕\n");
			break;
		case 6:
			p = head->next;
			while (p != NULL) {
				sum.yuan += p->cost.yuan;
				sum.jiao += p->cost.jiao;
				sum.fen += p->cost.fen;
				p = p->next;
			}
			convert(&(sum));
			printf("当前医院营业额:%d元 %d角 %d分\n\n", sum.yuan, sum.jiao, sum.fen);
			break;
		case 7:
			printf("科室   工号  姓名   级别   出诊日期\n");
			printf("1      10    王一    1     1 0 1 0 0 0 0  每周出诊2天\n");
			printf("1      11    王四    2     0 0 1 1 0 0 0  每周出诊2天\n");
			printf("1      12    王五    2     0 0 0 1 1 0 0  每周出诊2天\n");
			printf("1      13    赵二    4     0 1 1 0 0 0 1  每周出诊3天\n");
			printf("\n");
			printf("2       7    赵三    1     1 1 1 0 0 0 0  每周出诊3天\n");
			printf("2       9    王二    2     1 1 0 0 0 0 0  每周出诊2天\n");
			printf("2       8    赵五    2     1 0 1 0 0 0 0  每周出诊2天\n");
			printf("2       6    钱一    4     1 0 0 0 0 1 0  每周出诊2天\n");
			printf("\n");
			printf("3       3    钱二    1     1 1 0 1 0 0 0  每周出诊3天\n");
			printf("3       2    钱三    2     0 0 0 1 1 1 0  每周出诊3天\n");
			printf("3       4    钱五    3     1 1 0 0 0 0 0  每周出诊2天\n");
			printf("3       1    孙一    4     0 1 1 0 0 0 0  每周出诊2天\n");
			printf("\n");
			printf("4      16    孙二    1     1 1 1 0 0 0 0  每周出诊3天\n");
			printf("4      15    孙三    1     1 0 0 0 0 1 0  每周出诊2天\n");
			printf("4       5    孙五    2     1 1 1 0 0 0 0  每周出诊3天\n");
			printf("4      14    李一    4     0 0 0 0 1 0 1  每周出诊2天\n");
			printf("\n");
			printf("5      19    李二    1     0 0 0 1 1 1 0  每周出诊3天\n");
			printf("5      18    李三    1     0 0 0 1 0 1 0  每周出诊2天\n");
			printf("5      17    李五    3     0 1 1 1 0 0 0  每周出诊3天\n");
			printf("5      20    吴一    4     0 0 0 0 0 1 1  每周出诊2天\n");
			printf("\n");
			printf("6      23    吴二    1     0 0 0 1 1 1 1  每周出诊4天\n");
			printf("6      24    吴三    2     1 1 0 0 1 0 0  每周出诊3天\n");
			printf("6      21    吴四    3     0 0 0 1 1 0 0  每周出诊2天\n");
			printf("6      22    吴五    4     1 0 1 0 0 0 0  每周出诊2天\n");
			printf("\n");
			break;
		case 8:
			printf("请输入当前月、日:\n");
			scanf("%d%d",&m,&n);
			p = head->next;
			while (p != NULL) {
				if (p->cas.ifinhospital == 1&&m>=p->cas.inhospital1.startdate[0]&&m<= p->cas.inhospital1.planoutdate[0]&& n>= p->cas.inhospital1.startdate[1] && n <= p->cas.inhospital1.planoutdate[1])
					output(p);
				p = p->next;
			}
		}
		if (x == 0)
			break;
	}
}


6、modify.cpp

#include "base.h"

struct record * modify(struct record *p) {
	char x[100];
	int flag=0;
	struct record *a=head,*b;
	printf("\n********修改功能********\n");
	printf("请输入您想修改的诊疗记录挂号:\n");
	scanf("%s",x);
	while (a->next!= NULL) {
		if (strcmp(x, a->next->number) == 0) {
			flag = 1;
			b = a->next;
			if (b->next != NULL) {
				a->next = b->next;
				free(b);
			}
			else {
				p = a;
				free(b);
			}
			p = regist(p);
			printf("已修改成功!\n");
			break;
		}
		a = a->next;
	}
	if (flag == 0) {
		printf("不存在该条诊疗记录!自动返回上层\n");
	}
	return p;
}

7、delete.cpp
#include "base.h"

struct record* delete1(struct record* p) {
	char x[100];
	int flag = 0;
	struct record* a = head, * b;
	printf("\n********删除功能********\n");
	printf("请输入您想删除的诊疗记录挂号:\n");
	scanf("%s",x);
	while (a->next != NULL) {
		if (strcmp(x, a->next->number) == 0) {
			flag = 1;
			b = a->next;
			if (b->next != NULL) {
				a->next = b->next;
				free(b);
			}
			else {
				p = a;
				p->next = NULL;
				free(b);
			}
			printf("\n已删除!\n");
			break;
		}
		a = a->next;
	}
	if (flag == 0) {
		printf("不存在该条诊疗记录!自动返回上层\n");
	}
	return p;
}


8、main.cpp  //主函数文件
#include "base.h"

struct record* head;

int main() {
	struct record  *t;          //head是所创建的诊疗记录链表的哨兵节点,t是当前链表指针所在的位置
	head = (struct record*)malloc(sizeof(struct record));
	t = head;
	t->next = NULL;
	if (t == NULL) {
		printf("申请空间失败,程序中止。 \n");
		return 0;
	}
	int x;
	while (1) {
		printf("\n          ********主菜单********\n\n");
		printf("           |  1.从文件中录入  |\n");
		printf("           |  2.挂号          |\n");
		printf("           |  3.修改          |\n");
		printf("           |  4.删除          |\n");
		printf("           |  5.查询          |\n");
		printf("           |  6.保存          |\n");
		printf("           |  0.退出          |\n");
		printf("\n          *******欢迎使用********\n");
		scanf("%d", &x);
		switch (x) {
		case 0:
			printf("谢谢使用!\n");
			return 0;
		case 1:
			t = add(t);
			break;
		case 2:
			t = regist(t);
			break;
		case 3:
			t = modify(t);
			break;
		case 4:
			t = delete1(t);
			break;
		case 5:
			search();
			break;
		case 6:
			save();
			break;
		default:
			printf("输入有误!请重新输入:\n");
		}
	}
	return 0;
}

从文件导入功能用到的外部文件:test.txt, 需要和程序放到同一目录下

11040101  1 1 12 30      11 楚一 20  4 钱五 3 3  1 1 0 0 0 0 0
1 0 0  12 9 0 21 8 0 -1

12010118   1 18 7 30     12 楚二 30  1 孙一 4 3   0 1 1 0 0 0 0
0 1 1   健胃消食片 12 0 0 1 over  1 18 1 24  3000 0 0 

13160214  2 14  8 20     13 楚三  28  16 孙二 1 4    1 1 1 0 0 0 0
0 0 0 

14150217  2 17  16 29    14 楚四  21  15 孙三 1 4    1 0 0 0 0 1 0
1 0 0   7 8 0 -1

15050311  3 11  9 12      15 楚五  22   5  孙五  2 4   1 1 1 0 0 0 0
0 0 0 

01140322  3 22  7 10       1 冯一  13    14 李一 4 4   0 0 0 0 1 0 1
0 0 1  3 22  3  24  1200 0 0 

09031012  10 12 21 31   9  陈四 19    3 钱二 1 3   1 1 0 1 0 0 0
0 0 1  10 12 10 16  6000 0 0 

10021014  10 14 10 10  10 陈五 19     2 钱三 2 3  0 0 0 1 1 1 0
0 0 1  10 14  10 15  1500 0 0 

02190413  4 13  8 12        2 冯二 14    19 李二 1 5   0 0 0 1 1 1 0
1 0 0 399 0 0 -1

03180423  4 23  12 12      3 冯三 15    18 李三 1 5   0 0 0 1 0 1 0
0 1 0  止咳糖浆  15 0 0 3 over

04170522  5 22  6 40        4 冯四 17    17  李五 3 5   0 1 1 1 0 0 0
0 0 1  5 22 5 27  2800 0 0 
 
05200524  5 24  17 0      5 冯五 16    20 吴一  4 5   0 0 0 0 0 1 1
1 0 0  15 0 0 -1

06230626  6 26  16 0     6 陈一 17     23 吴二 1 6    0 0 0 1 1 1 1
0 1 1 枇杷露 12 9 9 2 over  6 26 6 27 3000

07240628  6 28  15 0     7 陈二 18   24 吴三 2 6    1 1 0 0 1 0 0
1 0 0 12 8 8 -1

08210721  7 21  17 0     8 陈三 18   21 吴四 3 6    0 0 0 1 1 0 0
0 1 0  止咳糖浆 15 0 0 3 over

09220731  7 31  12 0     9  陈四 19  22 吴五 4 6    1 0 1 0 0 0 0
1 0 0  12 4 4 -1

10100808  8  8   13 0     10 陈五 19   10 王一  1 1   1 0 1 0 0 0 0
1 0 0  25 9 9 -1

11110811  8  11  20 0    11 楚一 20   11 王四 2 1   0 0 1 1 0 0 0 
1 0 0   23 8 8 -1

12120907  9  7   18 0     12 楚二 30   12 王五 2 1  0 0 0 1 1 0 0
0 0 1  9 7  9 9  2000 0 0 

04130910  9 10 12 0      4 冯四 17    13 赵二 4 1  0 1 1 0 0 0 1
1 0 0  12 3 8  1 5 0  -1

01101006  10 6 19 50      1 冯一 13  10 王一  1 1  1 0 1 0 0 0 0
1 0 0  13 0 0  12 5 0 -1 

02111006  10 6 20 8      2 冯二 14   11 王四 2 1  0 0 1 1 0 0 0 
0 1 0  感康 24 8 0  2  华素片 9   9 0 2 over

03121007  10 7 20 12      3 冯三 15   12 王五 2 1  0 0 0 1 1 0 0
1 0 0  99 1 3  10 0 2 -1

05071008  10 8 21 11       5 冯五 16   7  赵三 1 2   1 1 1 0 0 0 0
1 1 0  12 8 0 -1 华素片 9 9 0 4 over

06091009  10 9  21 14      6 陈一 17   9 王二  2 2   1 1 0 0 0 0 0
0 0 1 10 9 10 12 2000 0 0

07081010  10 10 21 19     7 陈二 18      8 赵五 2 2   1 0 1 0 0 0 0
0 1 0  金嗓子喉宝  8 8 0 2 over 

08061011  10 11 21 22     8 陈三 18      6 钱一 4 2  1 0 0 0 0 1 0
1 0 1 20 5 0 12 8 0 -1 10 11 10 15  4000 0 0 

09031012  10 12 21 31     9  陈四 19     3 钱二 1 3   1 1 0 1 0 0 0
0 0 1  10 12 10 16  6000 0 0 

10021014  10 14 10 10    10 陈五 19      2 钱三 2 3  0 0 0 1 1 1 0
0 0 1  10 14  10 15  1500 0 0 

11041014  10 14  12 0   11 楚一 20  4 钱五 3 3  1 1 0 0 0 0 0
1 0 0  12 0 0  -1


以上就是全部啦,感谢阅读。

你可能感兴趣的:(编程之路,c语言,开发语言)