学生健康登记系统

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct Node *list=NULL;
struct Student
{
    char num[10];
    char name[20];
    char academy[30];
    float temperature;
    int cough;
    int health;
    char time[10];
    char date[10];
};
//链表节点
struct Node
{
    struct Student data;
    struct Node *next;
};
//创建头节点
struct Node *createList()
{
    struct Node *head=(struct Node *)malloc(sizeof(struct Node));
    head->next=NULL;
    return head;
}
//创建节点
struct Node *createNode(struct Student data)
{
    struct Node *newNode=(struct Node *)malloc(sizeof(struct Node));
    newNode->data=data;
    newNode->next=NULL;
    return newNode;
}
//插入链表  尾插法
void InsertNode(struct Node *head,struct Student data)
{
    struct Node *newNode=createNode(data);
    static struct Node *tail=NULL;
    if(head->next==NULL)
    {
        head->next=newNode;
    }
    else
    {
        tail->next=newNode;
    }
    tail=newNode;
}
//读取文件
void readFile(char *fileName,struct Node *list)
{
    FILE *fp=fopen(fileName,"r");
    if(fp==NULL)
    {
        //文件为空
        fp=fopen(fileName,"w");
    }
    struct Student student;
    while(fscanf(fp,"%s\t%s\t%s\t%f\t\t%d\t%d\t%s\t%s",
                 student.num,student.name,student.academy,&student.temperature,
                 &student.cough,&student.health,student.time,student.date)!=EOF)
    {
        InsertNode(list,student);
        memset(&student,0,sizeof(student));
    }
    fclose(fp);

}
//写文件
void saveFile(char *fileName,struct Node *list)
{
    FILE *fp=fopen(fileName,"w");
    struct Node *start=list->next;
    while(start!=NULL)
    {
        fprintf(fp,"%s\t%s\t%s\t%.2f\t\t%d\t%d\t%s\t%s\n",
                start->data.num,start->data.name,start->data.academy,
                start->data.temperature,start->data.cough,start->data.health,
                start->data.time,start->data.date);
        start=start->next;
    }
    fclose(fp);
}

//打印
void Print(struct Node *head)
{
    struct Node *start=head->next;
    printf("学号\t\t姓名\t学院\t\t温度\t是否咳嗽\t是否健康\t时间\t日期\n");
    while(start!=NULL)
    {

        printf("%s\t%s\t%s\t%.2f\t\t%d\t%d\t\t%s\t%s\n",
               start->data.num,start->data.name,start->data.academy,start->data.temperature,start->data.cough,start->data.health,
               start->data.time,start->data.date);
        start=start->next;
    }
}
//增加信息
struct Student Input()
{
    struct Student student;
    char AcadamyNum[5];
    printf("请录入信息:\n");
    do
    {
        printf("学生学号(9位):");
        scanf("%s",student.num);
    }
    while(strlen(student.num)!=9); //学号有九位
    printf("学生姓名:");
    scanf("%s",student.name);
    printf("温度:");
    scanf("%f",&student.temperature);
    printf("是否咳嗽(0:不咳嗽,1:咳嗽):");
    scanf("%d",&student.cough);
    printf("时间(xx:xx):");
    scanf("%s",student.time);
    do
    {
        printf("日期(8位):");
        scanf("%s",student.date);
    }
    while(strlen(student.date)!=8);

    //根据温度和咳嗽判断是否健康

    if(student.temperature<37.3&&student.cough==0)
    {
        //温度低于37.3 且不咳嗽
        student.health=1;
    }
    else
    {
        student.health=0;
    }
    //根据学院编号查找学院
    //裁剪出学院编号

    AcadamyNum[0]=student.num[4];
    AcadamyNum[1]=student.num[5];
    AcadamyNum[2]='\0';
    if(!strcmp(AcadamyNum,"01"))
    {
        strcat(student.academy,"通信学院");
    }
    else if(!strcmp(AcadamyNum,"02"))
    {
        strcat(student.academy,"计算机学院");
    }
    else if(!strcmp(AcadamyNum,"03"))
    {
        strcat(student.academy,"光电学院");
    }
    else if(!strcmp(AcadamyNum,"04"))
    {
        strcat(student.academy,"自动化学院");
    }
    else if(!strcmp(AcadamyNum,"05"))
    {
        strcat(student.academy,"经管学院");
    }
    else if(!strcmp(AcadamyNum,"06"))
    {
        strcat(student.academy,"研究生学院");
    }
    else if(!strcmp(AcadamyNum,"07"))
    {
        strcat(student.academy,"外语学院");
    }
    else if(!strcmp(AcadamyNum,"08"))
    {
        strcat(student.academy,"安法学院");
    }
    else if(!strcmp(AcadamyNum,"09"))
    {
        strcat(student.academy,"体育学院");
    }
    else if(!strcmp(AcadamyNum,"10"))
    {
        strcat(student.academy,"传媒学院");
    }
    else if(!strcmp(AcadamyNum,"11"))
    {
        strcat(student.academy,"先进制造学院");
    }
    else if(!strcmp(AcadamyNum,"12"))
    {
        strcat(student.academy,"马克思主义学院");
    }
    else
    {
        printf("学生学号输入错误\n");
    }
    return student;
    //插入节点
    //InsertNode(list,student);
}
//打印单个节点信息
void PrintOneNode(struct Node *OneNode)
{
    struct Node *temp=OneNode;
    printf("%s\t%s\t%s\t%.2f\t\t%d\t%d\t\t%s\t%s\n",
           temp->data.num,temp->data.name,temp->data.academy,temp->data.temperature,temp->data.cough,temp->data.health,
           temp->data.time,temp->data.date);
}

//查找节点
struct Node *SearchNode(struct Node *list,char *target,char *date)
{
    struct Node *temp=list->next;
    if(temp==NULL)
    {
        return NULL;
    }
    else
    {
        while(strcmp(temp->data.num,target)||strcmp(temp->data.date,date))//根据学号和日期查询
        {
            temp=temp->next;
            if(temp==NULL)
            {
                return temp;
            }
        }
        return temp;
    }

}
//根据学号和姓名查询  xx日期前的数据
struct Node *StaticNode(struct Node *list,char *target,char *date)
{
    struct Node *temp=list->next;
    if(temp==NULL)
    {
        return NULL;
    }
    else
    {
        while((strcmp(temp->data.num,target)&&strcmp(temp->data.name,target))||(strcmp(temp->data.date,date)>0))
        {
            temp=temp->next;
            if(temp==NULL)
            {
                return temp;
            }
        }
        return temp;
    }

}
//查找信息
void Search()
{
    char num[20],date[20],filename[60];
    struct Node *staticList=createList();
    printf("请输入学号或姓名:");
    scanf("%s",num);
    do
    {
        printf("请输入当前日期(8位):");
        scanf("%s",date);
    }
    while(strlen(date)!=8);
    struct Node *temp=StaticNode(list,num,date);
    if(temp==NULL)
    {
        printf("未查找到该生\n");
    }
    else
    {
        printf("学号\t\t姓名\t学院\t\t温度\t是否咳嗽\t是否健康\t时间\t日期\n");
        while(temp!=NULL)
        {
            PrintOneNode(temp);
            InsertNode(staticList,temp->data);
            temp=StaticNode(temp,num,date);
        }
    }
    saveFile("data2.txt",staticList);
}
//修改信息
void Update()
{
    char num[20],target[20],date[20];
    struct Student student;
    printf("请输入学号:");
    scanf("%s",num);
    do
    {
        printf("请输入日期(8位):");
        scanf("%s",date);
    }
    while(strlen(date)!=8);
    struct Node *temp=SearchNode(list,num,date);
    if(temp==NULL)
    {
        printf("未查找到该生\n");
    }
    else
    {
        printf("学号\t\t姓名\t学院\t\t温度\t是否咳嗽\t是否健康\t时间\t日期\n");
        PrintOneNode(temp);
        student=Input();
        temp->data=student;
    }
}
//删除节点
void DeleteNode(struct Node *head,char *num,char *date)
{
    struct Node *previous=head;
    struct Node *posNode=head->next;
    if(posNode==NULL)
    {
        printf("链表为空,无删除信息\n");
        return;
    }
    else
    {
        while(strcmp(posNode->data.num,num)||strcmp(posNode->data.date,date))//根据学号和日期删除
        {
            previous=posNode;
            posNode=posNode->next;
            if(posNode==NULL)
            {
                printf("未搜索到删除信息\n");
                return;
            }
        }
        previous->next=posNode->next;
        free(posNode);
    }

}

void Delete()
{
    char num[20],date[20];
    printf("请输入学号:");
    scanf("%s",num);
    do
    {
        printf("请输入日期(8位):");
        scanf("%s",date);
    }
    while(strlen(date)!=8);
    DeleteNode(list,num,date);
}
//统计某日的异常学生数据
void StaticAbnormal()
{
    struct Node *AbnormalList=createList();
    struct Node *start=list->next;
    char date[20];
    do
    {
        printf("请输入日期(8位):");
        scanf("%s",date);
    }
    while(strlen(date)!=8);
    while(start!=NULL)
    {
        if(start->data.health!=1&&!strcmp(start->data.date,date))
        {
            InsertNode(AbnormalList,start->data);
        }
        start=start->next;
    }
    saveFile("data3.txt",AbnormalList);
}
//系统界面
void keydown()
{
    int key;
    struct Student student;
    scanf("%d",&key);
    switch(key)
    {
    case 1:
        printf("===========1.录入信息===========\n");
        student=Input();
        //插入节点
        InsertNode(list,student);
        saveFile("student.txt",list);
        break;
    case 2:
        printf("===========2.修改功能===========\n");
        Update();
        saveFile("student.txt",list);
        break;
    case 3:
        printf("===========3.删除功能===========\n");
        Delete();
        saveFile("student.txt",list);
        break;
    case 4:
        printf("===========4.查找功能===========\n");
        Search();
        break;
    case 5:
        printf("===========5.浏览功能===========\n");
        Print(list);
        break;
    case 6:
        printf("===========6.统计当天异常学生===========\n");
        StaticAbnormal();
        break;
    }
}
void Menu()
{
    printf("===========[学生健康管理系统]===========\n");
    printf("===========1.录入信息===========\n");
    printf("===========2.修改功能===========\n");
    printf("===========3.删除功能===========\n");
    printf("===========4.查找功能===========\n");
    printf("===========5.浏览功能===========\n");
    printf("===========6.统计当天异常学生===\n");
    printf("================================\n");
    printf("请输入(1-5):");
}

int main()
{
    list=createList();
    readFile("student.txt",list);
    while(1)
    {
        Menu();
        keydown();
        system("pause");
        system("cls");
    }
    return 0;
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
数据库课程设计——健康档案管理系统 课 题: 健康档案治理系统 目 录 1. 课程设计的目的和意义…………………………………2 1. 课程设计的目的 …………………………………………2 2. 课程设计的意义 …………………………………………2 需求分析…………………………………………………3 2.1、数据流图……………………………………………………4 2.2、数据字典……………………………………………………7 三、概要结构设计……………………………………………10 四、逻辑结构设计……………………………………………13 五、物理结构设计……………………………………………13 总结 …………………………………………………………15 参考文献 ……………………………………………………16 一、课程设计的目的和意义 1.1、课程设计的目的 数据库课程设计是数据库原理及应用实践环节极为重要的一部分,其目的要紧是为了 加强学生对数据库差不多概念、原理和技术的把握,结合实际的操作和设计,巩固课堂 教学内容,将理论与实际相结合,强化学生的实践意识,从而提高学生的实际动手能力 和创新能力。通过课程设计,能够培养学生分析问题、解决问题以及自学能力,提高和 加强学生的运算机应用与软件开发能力,使学生熟练把握数据库设计工具的使用,提高 从事数据库系统建设和治理工作的差不多技能和能力。 2. 课程设计的意义 课程设计是学完基础知识后必须进行的一个实践环节。进行课程设计: 有利于基础知识的明白得,学生能够把握一些信息时代生存与进展必需的信息技术基 础知识和差不多技能,具备了在日常生活与学习中应用信息技术解决问题的差不多态度 与差不多能力; 有利于逻辑思维的锤炼 ,在许多常规学科的日常教学中,我们不难发觉如此一个现象,许多学生的思维常常处 于纷乱的状态。写起文来前言不搭后语,解题步骤纷乱,这些差不多上缺乏思维训练的 结果。程序设计是公认的、最能直截了当有效地训练学生的创新思维,培养分析问题、 解决问题能力的学科之一。即使一个简单的程序,从任务分析、确定算法、界面布局、 编写代码到调试运行,整个过程学生都需要有条理地构思,这中间有推测设想、判定推 理的抽象思维训练,也有分析问题、解决问题、推测目标等能力的培养; 有利于与其他学科的整合 ,在程序设计中,我们能够解决其它学科有关问题,也利用其它课程的有关知识来解决 信息技术中比较抽象专门难明白得的知识。在信息技术课中整合其它学科的知识,发挥 信息技术的优势; 有利于治学态度的培养, 程序设计中,语句的语法和常量变量的定义都有严格的要求,有时输了一个中文标点、 打错了一个字母,编译就不能通过,程序无法正常运行。程序设计初学时期,学生经常 会犯如此的错误,可能要通过几次乃至十多次的反复修改、调试,才能成功,但这种现 象会随着学习的深入而慢慢改观。这当中就能培养严谨治学、不怕失败、百折不挠的科 学精神和态度。 二、 需求分析 任务:设计一个健康档案治理系统 1、功能要求: 该系统健康文件包括病历文件和体检文件。 1. 登记学生健康信息插入健康文件; 2. 修改 修改一个学生健康档案记录; 3. 删除 删除学生健康档案记录; 4. 查询 能够组合各种条件进行查询,显示学生健康信息并打印健康文件报表; 5. 统计 对学生的差不多健康状况进行各种必要的统计和分析,由一样统计和动态分析两 种。一样统计包括计数和求平均值;动态分析由健康历史求出平均年增长值和年增长 率。 2、数据要求: 体检文件:学号、姓名、性别、系别、年龄、身高、体重、胸围、日期 病历文件:学号、姓名、性别、系别、 诊断、日期 在这次的课程设计中,用户要求我们对该系统健康文件实现学生信息登记、修 改、删除、查询、统计等操作,其中健康文件还包含病历文件和体检文件。在病历文 件中的数据要求有学号、姓名、性别、系别、 诊断、日期,而体检文件中的数据要求有学号、姓名、性别、系别、年龄、身高、体 重、胸围、日期。而为了使那个健康档案治理系统的设计能够更加接近现实生活,并 充分考虑到今后可能的扩充和改变,我们在里面加了一些相应的东西,比如我们将病 历文件和体检文件都看成是专门多学生的分类,每个学生都有一份相应的病历文件和 体检文件,文件中是他们不同时期的病历表和体检表,而病历表的属性不止包括学号 、姓名、性别、系别、 诊断、日期,还有医疗记录和是否住院等,体检表中又包含体检项目,而身高、体重 、胸围等均包含在项目名称中。 2.1、数据流图 2.2、数据字典(我负责加工条目) 1. 数据流条目 数据流名称:原始数据 简述:医务室向健康档案治理系统输入的学生的体检和病历数据 来源:医务室 去向:健康档案治理系统 组成:学号+姓名+性别+系别+年龄+身高+体重

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

已忘了

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值