医院挂号就诊系统

2017-06-26  本文已影响25人  幻想无极
//
//  main.c
//  c_test
//
//  Created by tqh on 2017/6/26.
//  Copyright © 2017年 tqn. All rights reserved.
//

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>

#define Num 100 //排队号码将以100后开始

static int lists = 1; //普通挂号的人员
//static int treat = 1; //急诊挂号的人员

static int aa=1; //没有去用指针,而是采用aa,bb来纪录挂号者的号码
//static int bb=1;    

typedef struct Node //链队的定义
{
    int data;
    struct Node *next;
}QueueP;

typedef struct
{
    QueueP *front;
    QueueP *rear;
}LinkQueue;

int Patient(LinkQueue *q) //病人挂号排队程序
{
    QueueP *p;
    p=(QueueP *)malloc(sizeof(QueueP));
    
    p->data=lists++;//取号+1
    p->next=NULL;
    q->rear->next=p;
    q->rear=p;
    
    printf(" +----------挂号成功,您的排队号码为:---------+\n\n %d\n\n",Num + p->data);
    printf(" +-------------您当前的位置为:%2d-------------+\n",lists-1);
    
    struct tm *ptime;
    time_t t;
    t=time(NULL);
    ptime=localtime(&t);
    
    printf(" +--------------现在时间是: %d:%d------------+\n",ptime->tm_hour,ptime->tm_min);

    printf(" +------------------挂号完成-------------------+\n");

    return (lists-1);
}

void Doctor(int z)//医生呼叫程序
{
    while (1) {
        if(z == 0){
            printf(" 现在暂时没有病人排队就医!\n");
            printf(" 请等待(按11退出就诊系统~)~~\n\n");
            
            char be[5]="11";
            scanf("%s",be);
            if(strcmp(be,"11")!=0)
            {
                continue;
            }
            else
                break;
        }
        else
        {
            printf(" 现在排队就诊的有%d个人 \n",z);

            printf(" 请核对就诊的病人挂号号码是否为:\n");
            printf(" %d\n\n",Num+aa++);
            printf("就诊完毕请输入任意键(按11退出医诊系统~)\n\n");
            char ae[5]="11";
            scanf("%s",ae);
            //比较字符串是否相同
            if(strcmp(ae,"11")!=0)
            {
                z--;//挂号病人-1
            }
            else
            {
                break;
            }
        }
    }
}


int main(int argc, const char * argv[]) {
    static int z=0;
    
    int choice = 0;
    
    while (1){
//        printf("输入任意键开始系统...\n");
//        scanf("%d",&choice);
        printf("\n\n +--------------------------------------------+\n");
        printf(" | 欢迎来到本医院排队就诊 |\n");
        printf(" +--------------------------------------------+\n\n");
        printf(" +---------------请选择您要的功能:------------+\n");
        printf(" +--------------------------------------------+\n");
        printf(" | 1、就医挂号 |\n");
        printf(" | 2、医生呼叫 |\n");
        printf(" | 0、退出系统 |\n");
        printf(" +--------------------------------------------+\n\n");
        scanf("%d",&choice);
        LinkQueue *q;
        q=(LinkQueue *)malloc(sizeof(LinkQueue));
        q->front=(QueueP *)malloc(sizeof(QueueP));
        q->rear=q->front;
        
//        printf("输入的为:%d", choice);
        
        switch (choice) {
            case 0:
                printf("\n");
                exit(1);
                break;
            case 1:
                z = Patient(q);//挂号+1
                break;
            case 2:
                Doctor(z);
                break;
            default:
                printf(" +-------------------输入错误!----------------+\n\n");
                break;
        }
    }
    
    return 0;
}

上一篇下一篇

猜你喜欢

热点阅读