| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1402 人关注过本帖
标题:程序不知道哪有问题,请帮忙找下
只看楼主 加入收藏
pl123586
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2016-10-13
结帖率:0
收藏
 问题点数:0 回复次数:2 
程序不知道哪有问题,请帮忙找下
注:代码用Vc++6.0正常运行,但PRINT函数部分内容不能显示在屏幕中,谁能告诉我原因
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <io.h>
#include <string.h>
#include <time.h>
#define MAX 10
#define price 0.01
typedef struct time{
    int hour;
    int min;
}Time;
typedef struct node{
  char num[20];
  Time reach;
  Time leave;
}CarNode;
typedef  struct NODE{
    CarNode *stack[MAX+1];
    int top;   
}SeqStackCar;
typedef struct car{
    CarNode *data;
    struct car *next;
}QueueNode;
typedef struct Node{
    QueueNode *head;
    QueueNode *rear;
}LinkQueueCar;

void InitStack(SeqStackCar*);
int InitQueue(LinkQueueCar*);
int Arrival(SeqStackCar*,LinkQueueCar*);
void Leave(SeqStackCar *,SeqStackCar *,LinkQueueCar *);
void PRINT(CarNode *p,int);
void List(SeqStackCar,LinkQueueCar);
void List1(SeqStackCar *);
void List2(LinkQueueCar *);
void main(){
    SeqStackCar Enter,Temp;
    LinkQueueCar Wait;
    int ch;
    InitStack(&Enter);
    InitStack(&Temp);
    InitQueue(&Wait);
    while(1){
    printf("欢迎使用停车管理系统\n");
    printf("1.车辆到达\n");
    printf("2.车辆离开\n");
    printf("3.返回\n");
    printf("输入所需服务:\n");
    while(1){
        scanf("%d",&ch);
        if(ch>=1&&ch<=4) break;
        else printf("输入错误!重新选择:\n");
    }
    switch(ch){
        case 1:Arrival(&Enter,&Wait);break;
        case 2:Leave(&Enter,&Temp,&Wait);break;
        case 3:List(Enter,Wait);break;
        case 4:exit(0);
        default: break;}
    }
}

void InitStack(SeqStackCar *s){
    int i;
    s->top=0;
    for(i=0;i<20;i++){
        s->stack[s->top]=NULL;
    }
}
int InitQueue(LinkQueueCar *Q){
    Q->head=(QueueNode *)malloc(sizeof(QueueNode));
    if(Q->head!=NULL){
        Q->head->next=NULL;
        Q->rear=Q->head;
         return(1);
    }
      else return(-1);
    }
int Arrival(SeqStackCar *Enter,LinkQueueCar *w){
    CarNode *p;
    QueueNode *t;
    p=(CarNode *)malloc(sizeof(CarNode));
    flushall();
    printf("输入车牌号码:\n");
    gets(p->num);
    if(Enter->top<MAX){
    Enter->top++;
    printf("该车在第%d号位\n",Enter->top);
    printf("该车进入停车场的时间\n");
    scanf("%d:%d",&(p->reach.hour),&(p->reach.min));
    while(p->reach.hour<0||p->reach.hour>23||p->reach.min<0||p->reach.min>59){
        printf("输入时间错误,重新输入:\n");
        scanf("%d:%d",&(p->reach.hour),&(p->reach.min));
    }
    Enter->stack[Enter->top]=p;
    return(1);}
    else
    {
        printf("停车场已满\n");
        t=(QueueNode *)malloc(sizeof(QueueNode));
        t->data=p;
        t->next=NULL;
        w->rear->next=t;
        w->rear=t;
        return(1);
    }
}
void Leave(SeqStackCar *Enter,SeqStackCar *Temp,LinkQueueCar *w)
{
    int room;
    CarNode *p,*t;
    QueueNode *q;
    if(Enter->top>0){
        printf("输入车在停车场位置(1-%d):\n",Enter->top);


     while(1){
              scanf("%d",&room);

            if(room>=1&&room<=Enter->top)
            break;
            else printf("错误!请重选:");
        }
        while(Enter->top>room){
            Temp->top++;
            Temp->stack[Temp->top]=Enter->stack[Enter->top];
            Enter->stack[Enter->top]=NULL;
            Enter->top--;
        }
        p=Enter->stack[Enter->top];
        Enter->stack[Enter->top]=NULL;
        Enter->top--;
        while(Temp->top>=1){
            Enter->top++;
            Enter->stack[Enter->top]=Temp->stack[Temp->top];
            Enter->stack[Enter->top]=NULL;
            Temp->top--;
        }
        PRINT(p,room);
        if((w->head!=w->rear)&&(Enter->top<MAX)){
            q=w->head->next;
            t=q->data;
            Enter->top++;
            printf("候车场的%d号车进入第%d号位置!\n",t->num,Enter->top);
            printf("输入到达时间:\n");
            scanf("%d:%d",&(t->reach.hour),&(t->reach.min));   
        w->head->next=q->next;
     if(q==w->rear) w->rear=w->head;
          Enter->stack[Enter->top]=t;
          free(q);
}
        else printf("候车场没有车\n");}
        else printf("停车场没有车\n");
    }
void PRINT(CarNode *p,int room){
    int A1,A2,B1,B2;
    int a,b,c,d;
    printf("请输入离开时间:\n");
    scanf("%d:%d",&(p->leave.hour),&(p->leave.min));
    while(p->leave.hour<0||p->leave.hour>23){
        printf("输入错误!\n");
        printf("请重新输入离开时间:\n");
        scanf("%d%d",&p->leave.hour,&p->leave.min);   
    }
    if(0<(p->leave.min)&&(p->leave.min)<59){
        if(p->reach.hour<p->leave.hour){
         printf("离开车辆的车牌号:\n");
        puts(p->num);
        printf("其到达时间为:%d:%d\n",p->reach.hour,p->reach.min);
        printf("其离开时间为:%d:%d\n",p->leave.hour,p->leave.min);
        A1=p->reach.hour;
        A2=p->reach.min;
        B1=p->leave.hour;
        B2=p->leave.min;
        a=B2-A2;
        b=B1+A1;
        if(a>0){
        printf("该车应交费用为:%4.2f元!\n",(((b-1)*60+a)+1)*price);
        free(p);}
        else{
        printf("该车应交费用为:%4.2f元!\n",(((b*60+a)+1)*price));
        free(p);}
        }
        
        else{
            printf("离开车辆的车牌号:\n");
        puts(p->num);
        printf("其到达时间为:%d:%d\n",p->reach.hour,p->reach.min);
        printf("其离开时间为:%d:%d\n",p->leave.hour,p->leave.min);
        A1=p->reach.hour;
        A2=p->reach.min;
        B1=p->leave.hour;
        B2=p->leave.min;
        c=B1-A1;
        d=B2-A2;
        if(d<0){
        printf("该车应交费用为:%4.2f元!\n",(((c-1)*60+(-d))+1)*price);
        free(p);}
        else{
        printf("该车应交费用为:%4.2f元!\n",(((c*60+d)+1)*price));
        free(p);}}

    }

    }

void List1(SeqStackCar *S){
    printf("你选的是停车场停车情况!\n");
    int i;
    if(S->top>0){
        printf("\n位置 到达时间 车牌号\n");
        for(i=1;i<=S->top;i++){
                printf("%d%d:%d\n",i,S->stack[i]->reach.hour,S->stack[i]->reach.min);
                 puts(S->stack[i]->num);     }
        }
        else printf("停车场里没有车!\n");
    }


void List2(LinkQueueCar *W){
    printf("你选择的是候车场停车情况!\n");
    QueueNode *p;
    p=W->head->next;
    if(W->head!=W->rear){
        printf("等待车辆车牌号为:\n");
        while(p!=NULL){
            printf("%d%c\n",p->data->num);
            p=p->next;
            
        }
    }
    else printf("便道里没有车!\n");
}
   
void List(SeqStackCar S,LinkQueueCar W){

    int flag,tag;
    flag=1;
    while(flag)
    {
        printf("**********查看**********\n");
        printf("1.车库   2.便道   3.返回\n");
        printf("************************\n");
        printf("请选择(1-3):[ ]\b\b");
        while(1)
        {
            scanf("%d",&tag);
            if(tag>=1&&tag<=3) break;
            else printf("错误!请重选(1-3):[ ]\b\b");
         }
        switch(tag)
        {
            case 1:List1(&S);break;/*列表显示车库信息*/
            case 2:List2(&W);break; /*列表显示便到信息*/
            case 3:flag=0;break;
            default: break;
         }
    }
}
搜索更多相关主题的帖子: price include 
2017-05-05 23:16
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:0 
但PRINT函数部分内容不能显示在屏幕中
这是啥意思呢

控制台下 一个屏幕显示的行数是有限的 不能完全显示是正常的

DO IT YOURSELF !
2017-05-07 07:15
wuyexinfei
Rank: 1
等 级:新手上路
帖 子:9
专家分:3
注 册:2017-5-7
收藏
得分:0 
这么长的代码 那么多printf 是哪个不能显示?我没搞懂在问什么
2017-05-07 17:25
快速回复:程序不知道哪有问题,请帮忙找下
数据加载中...
 
   



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

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