(1)程序流程图:
(2)结构体类型说明:
病人信息
struct bing
{
char id[10];
char name[10];
char sex[10];
int age;
};
医生信息
struct yi{
char id[10];
char name[10];
char sex[10];
char zhiwu[10];
int age;
};
(3)各模块的功能、和对应的函数介绍:
int nuwc();主界面。
int nuw();查询界面。
int zhuce();注册界面。
int denglu();登录界面。
int bingren();病人查询界面。
int yisheng();医生查询界面。
int guahao();挂号界面。
(4)程序代码:
#include <stdio.h>
#include<string.h>
struct bing
{
char id[10];
char name[10];
char sex[10];
int age;
};
struct yi{
char id[10];
char name[10];
char sex[10];
char zhiwu[10];
int age;
};
int main()
{
int nuwc();
int zhuce();
int denglu();
int guahao();
nuwc();
return 0;
}
int nuwc ()
{
int zhuce();
int denglu();
int t;
printf("\t\t\t***********欢迎来到华北水利水电大学医院挂号系统**********\n");
printf("\t\t\t 请选择您的操作:\n");
printf("\t\t\t|———————————————————————————|\n");
printf("\t\t\t| 1 注 册 |\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t| 2 登 录 |\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t| 3 信息查询 |\n");
printf("\t\t\t|———————————————————————————|\n");
printf("\t\t\t| 0 退 出 | \n");
printf("\t\t\t|———————————————————————————|\n");
printf("\t\t\t请输入您的选择【0-3】:");
scanf("%d", &t);
getchar();
while (t<0 || t>3)
{
printf("\t\t\t输入错误,请重新输入您的选择【0-3】:");
scanf("%d", &t);
}
switch (t)
{
case 0:
printf("\t\t\t\t\t\t退出成功\n\t\t\t\t\t 祝你身体健康!");
return 0;
case 1:
zhuce();
break;
case 2:
denglu();
break;
case 3:
printf("\n\n");
printf("\t\t\t\t\t 请先登录系统");
printf("\n\n");
nuwc();
break;
case 4:
printf("\n\n");
printf("\t\t\t\t\t 请先登录系统");
printf("\n\n");
nuwc();
break;
}
}
int zhuce ()
{
char s1,s2;
printf("\t\t\t输 入 姓 名 :") ;
scanf("%s", &s1);
printf("\t\t\t请输入你要设置的密码:");
scanf("%s", &s2);
nuwc();
}
int denglu()
{
int nuw();
printf("\t\t\t\t\t未注册请先注册\n") ;
char a[7];
char b[8];
int j = 0;
int i = 3;
char s3;
printf("\t\t\t输 入 姓 名 :") ;
scanf("%s", &s3);
printf("\t\t\t请输入你要设置的密码:");
getchar();
gets(a);
while (j < 3)
{
printf("\t\t\t\t请你输入密码:");
gets(b);
if (strncmp(a, b,7) == 0) {
printf("\t\t\t\t\t\t登录成功!\n");
nuw ();
break;
}
j++;
if ((i - j) == 0)
{
printf("\t\t\t\t\t账号进入冻结状态");
return 0;
}
if(strncmp(a, b, 7) !=0)
{
printf("\t\t\t\t密码错误,请重新输入\n\n");
printf("你还有%d次机会,请你再次输入密码:\n", i-j);
}
}
return 0;
}
int nuw ()
{
int t;
int bingren();
int yisheng();
int guahao ();
printf("\t\t\t***********欢迎来到华北水利水电大学医院挂号系统**********\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t| 1 病人信息 |\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t| 2 医生信息 |\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t| 0 退 出 |\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t请输入您的选择【0-2】:");
scanf("%d", &t);
getchar();
while (t<0 || t>2)
{
printf("\t\t\t输入错误,请重新输入您的选择【0-2】:");
scanf("%d", &t);
}
switch (t)
{
case 0:
printf("\t\t\t\t\t\t退出成功\n\t\t\t\t\t 祝你身体健康!");
return 0;
case 1:
bingren();
break;
case 2:
yisheng();
break;
}
}
int bingren()
{ int guahao();
int yisheng();
bing a[6]={
{"1","病人1","男",12},
{"2","病人2","女",50},
{"3","病人3","女",12},
{"4","病人4","男",22},
{"5","病人5","男",52},
{"6","病人6","男",62}
};
int i;
printf("\n");
printf("\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t| 请输入病人编号 |\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t\t\t病人序号:");
scanf("%d",&i);
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t\t序号:%s 姓名:%s 性别:%s 年龄:%d岁\n",a[i-1].id,a[i-1].name,a[i-1].sex,a[i-1].age);
printf("\t\t\t|------------------------------------------------------|\n");
guahao();
}
int yisheng()
{ int guahao();
yi a[3]={
{"1","专家1","男","主任", 52},
{"2","专家2","女","副主任",42},
{"3","专家3","女","副主任",40}
};
int i;
printf("\n");
printf("\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t| 请输入专家序号 |\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t\t\t 输入专家序号1-3:");
scanf("%d",&i);
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t 序号:%s 姓名:%s 性别:%s 职务:%s 年龄%d 岁\n",a[i-1].id,a[i-1].name,a[i-1].sex,a[i-1].zhiwu,a[i-1].age);
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t| 请输入专家序号 |\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t\t\t 输入专家序号1-3:");
scanf("%d",&i);
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t 序号:%s 姓名:%s 性别:%s 职务:%s 年龄%d 岁\n",a[i-1].id,a[i-1].name,a[i-1].sex,a[i-1].zhiwu,a[i-1].age);
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t| 请输入专家序号 |\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t\t\t 输入专家序号1-3:");
scanf("%d",&i);
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t 序号:%s 姓名:%s 性别:%s 职务:%s 年龄%d 岁\n",a[i-1].id,a[i-1].name,a[i-1].sex,a[i-1].zhiwu,a[i-1].age);
printf("\t\t\t|------------------------------------------------------|\n");
bingren();
}
int guahao()
{
int t;
printf("\t\t\t请输入你挂号的专家号【0-3】:\n");
printf("\n");
printf("\t\t\t***********欢迎来到华北水利水电大学医院挂号系统**********\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t| 1 专家一 |\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t| 2 专家二 | \n");
printf("\t\t\t|———————————————————————————|\n");
printf("\t\t\t| 3 专家三 |\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t| 0 退出 |\n");
printf("\t\t\t|------------------------------------------------------|\n");
printf("\t\t\t请输入您的选择【0-3】:");
scanf("%d", &t);
getchar();
while (t<0 || t>3)
{
printf("\t\t\t输入错误,请重新输入您的选择【0-3】:");
scanf("%d", &t);
}
switch (t)
{
case 0:
printf("\t\t\t\t\t\t退出成功\n\t\t\t\t\t 祝你身体健康!");
return 0;
case 1:
printf("\n");
printf("\t\t\t\t\t 专家1挂号成功");
break;
case 2:
printf("\n");
printf("\t\t\t\t\t 专家2挂号成功");
break;
case 3:
printf("\n");
printf("\t\t\t\t\t 专家3挂号成功");
break;
}
}