| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 587 人关注过本帖
标题:哪位高手帮我改正一下下面程序的错误?
只看楼主 加入收藏
xuming
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2009-11-24
结帖率:0
收藏
已结贴  问题点数:20 回复次数:7 
哪位高手帮我改正一下下面程序的错误?
            
#include <stdio.h>
#include <malloc.h>
#  define MAXQSIZE 50;                    /*排队队伍中的最多的人数*/
typedef  int  QElemType;
typedef struct {
    QElemType  *base;
    int  front;
    int  rear;
}SqQueue;
void SeeDoctor()
{
    int sel,flag=1,find,no,person;
    person=0;
    SqQueue Q;
    Q.base=(QElemType *)malloc(MAXQSIZE*sizeof(QElemType));
    if(!Q.base) exit(OVERFLOW);
    Q.front=Q.rear=0;   
    while (flag==1)                             
    {
           printf("1:排队 2:就诊 3:查看排队 4.不再排队,余下依次就诊 5:下班  请选择:");
        scanf("%d",&sel);
        switch(sel)
        {
        case 1:    printf("  >>输入病历号:");
            do
            {   
                scanf("%d",&no);
                find=0;
                while (person!=0&&!find)
                {   
                    if (Q.base[Q.front]==no)                           
                        find=1;
                    else
                        Q.front=(Q.front+1)%MAXQSIZE;   
                }
                if (find)
                    printf("  >>输入的病历号重复,重新输入:");
            } while (find==1);
            
            Q.base[Q.rear]=no;
            Q.rear=(Q.rear+1)%MAXQSIZE;
            person++;
            if(person==MAXQSIZE)printf("对不起人数已达最大!");

        case 2:    if (person==0)                /*队空*/
                    printf("  >>没有排队的病人!\n");
                else                                /*队不空*/
                {
                    
                      printf("  >>病人%d就诊\n",Q.base[Q.front]);
                    Q.front=(Q.front+1)%MAXQSIZE;
                    person--;
                       break;
          case 3:if (person==0)              /*队空*/
                       printf("  >>没有排列的病人!\n");
                 else                             /*队不空*/
                 {
                     
                     printf("  >>排队病人:");
                     while (person!=0)
                     {
                         printf("%d ",Q.base[Q.front]);
                         Q.front=(Q.front+1)%MAXQSIZE;
                     }
                     printf("\n");
                 }
                 break;
          case 4:if (person==0)            /*队空*/
                    printf("  >>没有排列的病人!\n");
                 else                            /*队不空*/
                 {
               
                     printf("  >>病人按以下顺序就诊:");
                     while (person!=0)
                     {
                         printf("%d ",Q.base[Q.front]);
                         Q.front=(Q.front+1)%MAXQSIZE;
                     }
                     printf("\n");
                }
                flag=0;                            /*退出*/
                break;
          case 5:if (person!=0)            /*队不空*/
                    printf("  >>请排队的病人明天就医!\n");
                 flag=0;                        /*退出*/
                    break;
        }
    }
}
void main()
{
    SeeDoctor();
}
搜索更多相关主题的帖子: include person 
2010-10-23 07:31
xuming
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2009-11-24
收藏
得分:0 
急啊,高手帮帮忙吧!
2010-10-23 08:11
寒风中的细雨
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:66
帖 子:1710
专家分:8645
注 册:2009-9-15
收藏
得分:10 
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>

#define MAXQSIZE 50                    /*排队队伍中的最多的人数*/
#define OVERFLOW -1

typedef  int  QElemType;

typedef struct
{
    QElemType  *base;
    int  front;
    int  rear;
}SqQueue;

void SeeDoctor()
{
    int sel,flag=1,find,no,person;
    person=0;
    SqQueue Q;
    Q.base=(QElemType *)malloc(MAXQSIZE*sizeof(QElemType));
    if(!Q.base)
        exit(OVERFLOW);
    Q.front=Q.rear=0;   
    while (flag==1)                             
    {
        printf("1:排队 2:就诊 3:查看排队 4.不再排队,余下依次就诊 5:下班  请选择:");
        scanf("%d",&sel);
        switch(sel)
        {
        case 1:   
            printf("  >>输入病历号:");
            do
            {   
                scanf("%d",&no);
                find=0;
                while (person!=0&&!find)
                {   
                    if (Q.base[Q.front]==no)                           
                        find=1;
                    else
                        Q.front=(Q.front+1)%MAXQSIZE;   
                }
                if (find)
                    printf("  >>输入的病历号重复,重新输入:");
            } while (find==1);
            
            Q.base[Q.rear]=no;
            Q.rear=(Q.rear+1)%MAXQSIZE;
            person++;
            if(person==MAXQSIZE)
                printf("对不起人数已达最大!");

        case 2:   
            if (person==0)                /*队空*/
                printf("  >>没有排队的病人!\n");
            else                                /*队不空*/
            {
                printf("  >>病人%d就诊\n",Q.base[Q.front]);
                Q.front=(Q.front+1)%MAXQSIZE;
                person--;
            }
            break;
        case 3:
            if (person==0)              /*队空*/
                printf("  >>没有排列的病人!\n");
            else                             /*队不空*/
            {
                     
                printf("  >>排队病人:");
                while (person!=0)
                {
                    printf("%d ",Q.base[Q.front]);
                    Q.front=(Q.front+1)%MAXQSIZE;
                }
                    printf("\n");
            }
            break;
        case 4:
            if (person==0)            /*队空*/
                printf("  >>没有排列的病人!\n");
            else                            /*队不空*/
            {
                printf("  >>病人按以下顺序就诊:");
                while (person!=0)
                {
                    printf("%d ",Q.base[Q.front]);
                    Q.front=(Q.front+1)%MAXQSIZE;
                }
                    printf("\n");
            }
            flag=0;                            /*退出*/
            break;
        case 5:
            if (person!=0)            /*队不空*/
                printf("  >>请排队的病人明天就医!\n");
            flag=0;                        /*退出*/
            break;
        }
    }
}

void main()
{
    SeeDoctor();
}
怎样工作 就不知道啦
2010-10-23 09:01
xuming
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2009-11-24
收藏
得分:0 
回复 3楼 寒风中的细雨
高手,还是有错误啊
'data' : undeclared identifier
2010-10-23 10:17
寒风中的细雨
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:66
帖 子:1710
专家分:8645
注 册:2009-9-15
收藏
得分:0 
图片附件: 游客没有浏览图片的权限,请 登录注册
2010-10-23 16:40
李岩
Rank: 2
等 级:论坛游民
帖 子:14
专家分:27
注 册:2010-10-8
收藏
得分:10 
楼主好厉害啊?能否收小弟为徒啊
2010-10-23 18:03
xuming
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2009-11-24
收藏
得分:0 
/*文件名:exp3-6.cpp*/
            
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>

#define MAXQSIZE 50      /*队列中允许的最多人数*/                  
#define OVERFLOW -1
typedef  int  QElemType;
typedef struct {
    QElemType  *base;
    int  front;
    int  rear;
}SqQueue;
void SeeDoctor()
{
    int sel,flag=1,find,no,person,head,person1,person2;
    person=0;
    SqQueue Q;
    Q.base=(QElemType *)malloc(MAXQSIZE*sizeof(QElemType));
    if(!Q.base) exit(OVERFLOW);
    Q.front=Q.rear=0;   
    while (flag==1)                             
    {
           printf("1:排队 2:就诊 3:查看排队 4.不再排队,余下依次就诊 5:下班  请选择:");
        scanf("%d",&sel);
        switch(sel)
        {
        case 1:    printf("  >>输入病历号:");
            do
            {   
                scanf("%d",&no);
                find=0;
                head=Q.front;
                while (head!=Q.rear&&!find)
                {   
                    if (Q.base[head]==no)                           
                        find=1;
                    else
                        head=(head+1)%MAXQSIZE;   
                }
                if (find)
                    printf("  >>输入的病历号重复,重新输入:");
            } while (find==1);
            
            Q.base[Q.rear]=no;
            Q.rear=(Q.rear+1)%MAXQSIZE;
            person++;
            if(person==MAXQSIZE)printf("对不起排队人数已达最大!不再接受排队。\n");
            person1=person;
            person2=person;
            break;

        case 2:    if (person==0)                /*队空*/
                    printf("  >>没有排队的病人!\n");
                else                                /*队不空*/
                {
                    head=Q.front;
                      printf("  >>病人%d就诊\n",Q.base[head]);
                    person--;
                    person1=person;
                    person2=person;
                    if(    person==0)
                    {
                        Q.front=Q.rear=0;
                    }
                    else
                        Q.front=(Q.front+1)%MAXQSIZE;
                }
                       break;
               
          case 3:if (person1==0)              /*队空*/
                       printf("  >>没有排列的病人!\n");
                 else                             /*队不空*/
                 {
                     head=Q.front;
                     printf("  >>排队病人:");
                     while (person1!=0)
                     {
                         printf("%d ",Q.base[head]);
                         head=(head+1)%MAXQSIZE;
                         person1--;
                     }
                     printf("\n");
                 }
                 break;
          case 4:if (person2==0)            /*队空*/
                    printf("  >>没有排列的病人!\n");
                 else                            /*队不空*/
                 {
                     head=Q.front;
                     printf("  >>病人按以下顺序就诊:");
                     while (person2!=0)
                     {
                         printf("%d ",Q.base[head]);
                         head=(head+1)%MAXQSIZE;
                         person2--;
                     }
                     printf("\n");
                }
                flag=0;                            /*退出*/
                break;
          case 5:if (person!=0)            /*队不空*/
                    printf("  >>请排队的病人明天就医!\n");
                 flag=0;                        /*退出*/
                    break;
        }
    }
}
void main()
{
    SeeDoctor();
}
2010-10-25 22:08
xuming
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2009-11-24
收藏
得分:0 
这是我改正后完全正确的程序,“寒风中的细雨”多谢了
2010-10-25 22:09
快速回复:哪位高手帮我改正一下下面程序的错误?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026441 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved