医院信息管理系统--顺序

/*在关系数据中,病人的信息由若干个基本表存储的,为了简便起见,我们假设所要检索和统计病人的信息存储在线性表p_inof中.每个记录即表元素为上述定义的结构体。
1. 根据病人id来检索病人信息,采用顺序比较好,并简述理由.用c描述。**答:因为顺序存储能方便的通过控制数组序号的方式进行检索,而链式存储需要控制指针指向相应的结点来完成。**
2. 若要经常添加和删除病人信息,则采用链式比较好,并且简述理由.用c描述。**答:因为链式存储能方便的通过指针指向要删除结点的下一个结点完成,而顺序存储需要移动要删除添加结点后面所有结点的位置**
3. 在医院信息系统(his)中统计分析时其中一个重要的模块,现要统计病人中患心脏病(假设病重类型为12),用c描述.
4. 在p_inof struct中为什么定义为病人患病的类型而不定义为患病的名称。**答:这样便于检索,归类和处理。**
*/

 


/*医院信息管理系统--顺序.cpp*/
#include<stdio.h>
#include<malloc.h>
#define MAXSIZE 100
typedef struct
{
 int id;
 char a[20];
 int illtype;
}illman;
typedef struct
{
 illman *m[MAXSIZE];
 int length;
}list;
list p_inof; /*将病人信息放在该线性表中*/

/*初使化链表的函数*/
void initlist(list *i_list)
{
 i_list=(list *)malloc(sizeof(list));
 i_list->length=0;
}
/*在表尾插入数据的函数*/
void input(list *i_list)
{
 int a,b,i;
 char n[20];
 while(i_list->length<MAXSIZE)
 {
  i_list->m[i_list->length]=(illman *)malloc(sizeof(illman));
  printf("/nInput the id: ");
  scanf("%d",&a);
  if(a==0)return;
  i_list->m[i_list->length]->id=a;
  printf("Input the name: ");
  scanf("%s",n);
  for(i=0;i<20;++i)
  i_list->m[i_list->length]->a[i]=n[i];
  printf("Input the illtype: ");
  scanf("%d",&b);
  i_list->m[i_list->length]->illtype=b;
  ++i_list->length;
 }
}
/*在线性表中查找所输入id号病人的信息*/
void search(list *i_list)
{
 int i;
 int id_num;
 list *m_list;
    m_list=i_list;
 printf("/nInput the patien'id you want to search :");
 scanf("%d",&id_num);
 for(i=0;i<m_list->length;++i)
  if(m_list->m[i]->id==id_num)
  {
    printf("/nThe illman's information is:/n");
    printf("************/n");
          printf("id:  %d/n",m_list->m[i]->id);
       printf("name:%s/n",m_list->m[i]->a);
       printf("illtype:%d/n",m_list->m[i]->illtype);
   
  }
   printf("************/n");
}
/*输出线性表中的数据的函数*/
void print(list *i_list)
{
 int i;
 printf("/n/nThe all illman's information is:/n");
 for(i=0;i<i_list->length;++i)
 {
  printf("************/n");
  printf("id:   %d/n",i_list->m[i]->id);
     printf("name: %s/n",i_list->m[i]->a);
  printf("illtype: %d/n",i_list->m[i]->illtype);
 }
 printf("************/n");
}
/*删除线性表中指定id的函数*/
void del(list *i_list)
{
 int i,j,id_num;
 printf("/nInput the patien'id you want to delete :");
 scanf("%d",&id_num);
 printf("The delete illman's information is:/n");
 for(i=0;i<i_list->length;++i)
 {
  if(i_list->m[i]->id==id_num)
  {
   printf("************/n");
   printf("id:   %d/n",i_list->m[i]->id);
   printf("name: %s/n",i_list->m[i]->a);
   printf("illtype: %d/n",i_list->m[i]->illtype);
   printf("************/n");
   for(j=i;j<i_list->length;++j)
       i_list->m[j]=i_list->m[j+1];
  }
 }
 --i_list->length;
}
/*计算线性表中患12类型病的病人个数的函数*/
void cout_ill(list *i_list)
{
 int cout=0,i,a;
 for(i=0;i<i_list->length;++i)
  if(i_list->m[i]->illtype==12)++cout;
 a=cout;
 printf("The the heart ill number is: %d/n",a);
}
/*输出选择菜单的函数*/
void print_mu()
{
  printf("/n*******************--menu--*******************/n");
  printf("   Input the patient's information input 1 ./n");
  printf("   Output the patien's information input 2 ./n");
  printf("   Delete the patien's information input 3 ./n");
  printf("   Search the patien with id input 4 ./n");
  printf("   conut the heart ill number input 5 ./n");
  printf("*********************menu*********************/n");
  printf("Input your choose:");
}

void main()
{
    int a,id_1;
    print_mu(); 
 while(1)
 {
     scanf("%d",&a);
     switch(a)
       {
         case 1:input(&p_inof);print_mu();break;
         case 2:print(&p_inof);print_mu();break;
         case 3:del(&p_inof);print_mu();break;
         case 4:search(&p_inof);print_mu();break;
   case 5:cout_ill(&p_inof);print_mu();break;
       }
 }
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值