数据结构、c语言-急!!!!为何以下程序执行第2功能离开车厂后在vc++6.0环境下程序会报错并终止运行,求解决方案

问题描述

急!!!!为何以下程序执行第2功能离开车厂后在vc++6.0环境下程序会报错并终止运行,求解决方案

#include "stdafx.h"
#include
#include
#include
#define max 5

#define pri 5

typedef struct time{

int year;
int day;
int month;
int hour;
int min;
}Time;

typedef struct node{

char num[10];
Time reach;
Time leave;
}Carinfo;

typedef struct car{
Carinfo *data;
struct car *next;
}queue;

typedef struct Node{
queue *lead;
queue *end;
}link;

typedef struct NODE{
Carinfo *b[max+1];
int top;
}Zhan;

void Zhaninit(Zhan *s){

 int i;
 s->top=0;
 for(i=0;i<=max;i++)
     s->b[s->top]=NULL;

}

int queueinit(link *U){

U->lead=(queue *)malloc(sizeof(queue));
if(U->lead!=NULL)
{
U->lead->next=NULL;
U->end=U->end;
return(1);
}
else return(-1);
}

int Arrival(Zhan *into,link *R){

Carinfo *p;
queue *t;
p=(Carinfo *)malloc(sizeof(Carinfo));
flushall();
printf("n车牌号:");
gets(p->num);
if(into->top<max)
{
    into->top++;
    printf("nn车辆在第%d位置.",into->top);
    printf("n到达时间:<例:2015 08 08 14:00>n");
    scanf("%d %d %d %d:%d",&(p->reach.year),&(p->reach.month),&(p->reach.day),&(p->reach.hour),&(p->reach.min));
    into->b[into->top]=p;
    return(1);
}
else
{
    printf("无法进场,请稍候!");
    t=(queue *)malloc(sizeof(queue));
    t->data=p;
    t->next=NULL;
    R->end->next=t;
    R->end=t;
    return(1);
}

}

void pay(Carinfo *p,int blank)
{

int n1,n2,m1,m2,consume;
printf("n离开的时间:");
scanf("%d %d %d %d:%d",&(p->leave.year),&(p->leave.month),&(p->leave.day),&(p->leave.hour),&(p->leave.min));
printf("n离开的车牌号为:");
puts(p->num);
printf("n其到达时间为: %d %d %d %d:%d",p->reach.year,p->reach.month,p->reach.day,p->reach.hour,p->reach.min);
printf("n离开时间为: %d %d %d %d:%d",p->leave.year,p->leave.month,p->leave.day,p->leave.hour,p->leave.min);
n1=p->reach.day;
n2=p->reach.hour;
m1=p->leave.day;
m2=p->leave.hour;
if(m2==n2&&m1>=n1)
{
consume=((m1-n1)*24+1)*pri;
}
else
{
    if(m2>n2&&m1>n1)
    {
        consume=((m1-n1)*24+(m2-n2))*pri;
    }
    else
    {
        if(m2<n2&&m1>n1)
        {
            consume=((m1-n1)*24+(m2-n2))*pri;
        }
    }
}

printf("n应交费用为: %d元",consume);
free(p);
}

void Leave(Zhan *into,Zhan *off,link *R)
{

int blank;
Carinfo *p,*t;
queue *q;

if(into->top>0)
{
    while(1)
    {
        printf("n选择在场车辆的位置/1--%d/:",into->top);
        scanf("%d",&blank);
        if(blank>=1&&blank<=into->top) break;
        else printf("n 错误: ");

    }
    while(into->top>blank)
    {
        off->top++;
        off->b[off->top]=into->b[into->top];
        into->b[into->top]=NULL;
        into->top--;
    }
    p=into->b[into->top];
    into->b[into->top]=NULL;
    into->top--;
    while(off->top>=1)
    {
        into->top++;
        into->b[into->top]=off->b[off->top];
        off->b[off->top]=NULL;
        off->top--;
    }
    pay(p,blank);

if((R->lead!=R->end)&&into->top
{
q=R->lead->next;
t=q->data;
into->top++;
printf("nn便道的%d号车进入车场第%d位置.",t->num,into->top);
printf("nn请输入%d号车进入车场的时间:",t->num);
scanf("%d %d %d %d:%d",&(t->reach.year),&(t->reach.month),&(t->reach.day),&(t->reach.hour),&(t->reach.min));
R->lead->next=q->next;
if(q==R->end) R->end=R->lead;
into->b[into->top]=t;
free(q);
}
else printf("n便道里没有车.n");
}
else printf("n停车场里没有车.");

}

void park1(link *R)

{
queue *p;
int i;
p=R->lead->next;
if(R->lead!=R->end)
{
printf("没有车!:n");
for(i=1; (p!=NULL); i++)
{
printf("第 %d 车辆.",i);
puts(p->data->num);
p=p->next ;
}
}

}

void park2(Zhan *S)

{
int i;
if(S->top>0)
{
printf("车场:");
printf("n n位置 到达时间 车牌号n");
for(i=1;i<=S->top;i++)
{
printf(" %d ",i);
printf("%d %d %d %d:%d ",S->b[i]->reach.year,S->b[i]->reach.month,S->b[i]->reach.day,S->b[i]->reach.hour,S->b[i]->reach.min);
puts(S->b[i]->num);
}
}
else
printf("这里没有车!n");
}

void park(Zhan U,link R)

{
int flag,tag;
flag=1;
while(flag)
{
printf("nnn 1 道路上 2 车场里 3 返回主菜单n");
printf("n请选择 1~3:");
while(1)
{
scanf("%d",&tag);
if(tag>=1 && tag<=3)
break;
else

        printf("n 输入有误,请重新选择 1~3:");
    }
    switch(tag)
    {
    case 1:park1(&R);
        break;
    case 2:park2(&U);
        break;
    case 3:flag=0;  system("cls");
        break;
    default:
        break;
    }
}

}

void main(int argc, char* argv[])
{
Zhan into,off;
link Wait;
int ch;
Zhaninit(&into);

Zhaninit(&off);
queueinit(&Wait);
system("color 0F");
while(1)
{
printf("nnnnnt ☆☆☆☆☆ 欢 迎 使 用 停 车 场 系 统. ☆☆☆☆☆tn");
printf("nnnt ▲◇◇◇◇◇◇ 1. 车辆进场信息录入.◇◇◇◇◇◇◇▲tn");
printf("nnnt ▲◇◇◇◇◇◇ 2. 车辆出场信息录入.◇◇◇◇◇◇◇▲tn");
printf("nnnt ▲◇◇◇◇◇◇ 3. 车辆列表信息显示.◇◇◇◇◇◇◇▲tn");
printf("nnnt ▲◇◇◇◇◇◇ 4. 退 出 系 统 .◇◇◇◇◇◇◇▲tnn");
printf("nt收费标准:按小时收费,未满一小时按一小时算,总停车时长不得超过一个月!tnn");
while(1)
{
printf(" 您想做些什么?: ");
scanf("%d",&ch);
if(ch>=1&&ch<=5)break;
else printf("n 输入有误,请重新选择: 1~4: ");
}
switch(ch)
{
case 1:Arrival(&into,&Wait);
break;

    case 2:Leave(&into,&off,&Wait);
        break;
    case 3:park(into,Wait);
        break;
    case 4:exit(0);
    default:
        break;
    }
}

}

解决方案

代码粘贴有错误:

        if((R->lead!=R->end)&&into->top {
            q=R->lead->next;

解决方案二:

多谢,程序已运行成功

解决方案三:

多谢,程序已运行成功

时间: 2024-08-28 12:22:03

数据结构、c语言-急!!!!为何以下程序执行第2功能离开车厂后在vc++6.0环境下程序会报错并终止运行,求解决方案的相关文章

跪求 帮忙-VC++6.0 环境下,怎么能够使程序运行后的黑框直接变成全屏显示

问题描述 VC++6.0 环境下,怎么能够使程序运行后的黑框直接变成全屏显示 VC++6.0 环境下,win32 console application下编一个什么样的程序能够使输出的黑框变成全屏?例如 #include main() { printf("你好n"); } 这个简单程序中添加上哪些代码就能够使输出的黑框直接占满整个电脑屏幕?麻烦哪位大侠给帮个忙,并把修改后的完整程序附上,小弟不胜感激!

jar-weblogic环境下调用接口报错,急,在线等!org.w3c.dom.Node.setUserData

问题描述 weblogic环境下调用接口报错,急,在线等!org.w3c.dom.Node.setUserData 之前在测试环境中测试是可以的,后来部署到正式环境就挂掉了,tomcat下也是正常的.项目的weblogic.xml也配置了优先加载项目的jar包,还是不行. ava.lang.LinkageError: loader constraint violation: when resolving interface method "org.w3c.dom.Node.setUserData

c-刚学数据结构写了个链表,调试无报错,一运行就显示“main.exe停止运行”。

问题描述 刚学数据结构写了个链表,调试无报错,一运行就显示"main.exe停止运行". 刚学数据结构,写了个链表,调试无误,一运行就显示"main.exe停止运行",很头疼,求大神指点..谢谢~ 代码如下: #include #include #define OK 1 #define ERROR 0 #define OVERFLOW -1 define LIST_INIT_SIZE 100 // 线性表存储空间的初始分配量 define LISTINCREMENT

工程-vc++6.0写的程序用vs2010打开需要改变些什么

问题描述 vc++6.0写的程序用vs2010打开需要改变些什么 要整理一个程序 ,不是自己写的,原来是vc++6.0写的,现在用vs2010打开报一些很奇怪的错,都指向头文件,complex 还有string 搞了很长时间了,哪位大神给解答一下,小弟感激不尽啊,谢谢 解决方案 这可能是头文件的错误.因为不同的编译器可能将库文件放在不同的头文件中,所以要想把错误改正,需要了解需要的头文件放在那个库中.其实用遵循统一标准的编译器就可以避免这些问题,可以用linux gcc 编译器! 解决方案二:

android程序,eclipse没报错,但是运行会意外停止

问题描述 android程序,eclipse没报错,但是运行会意外停止 本人刚开始学习android,跟着书写了个程序,这个程序是会有一个东西随着手指拖动而移动,编译完没有问题,但是在手机上运行的时候却是意外停止,错误显示在了MainActivity的第27行,我真不知道哪里错,代码和书上写的一模一样,求大神指导 MainActivity的代码: package com.example.test34; import android.app.Activity; import android.os.

c++-win32 C++应用程序放到Server08下连接oracle报错

问题描述 win32 C++应用程序放到Server08下连接oracle报错 程序是C++的,连接本地Oracle数据库,方法为 CoInitialize(NULL);ConnectionPtr conn; try{ conn.CreateInstance(_uuidof(Connection)); conn->Open("Provider=OraOLEDB.Oracle.1;Data Source=ORACLE;Persist Security Info=false;Password=

编译出错-用vs2013编译之前用vc++6.0写的程序报错

问题描述 用vs2013编译之前用vc++6.0写的程序报错 用vs2013编译之前用vc++6.0写的程序 以上是报错代码 错误 1 error MSB8021: The value '{0}' of the variable '{1}' is incompatible with the value '{2}' of the variable '{3}'. C:Program Files (x86)MSBuildMicrosoft.Cppv4.0V120Microsoft.CppBuild.t

mfc-MFC基于对话的编程,请问一下程序每一行都有什么用?(VC++6.0)

问题描述 MFC基于对话的编程,请问一下程序每一行都有什么用?(VC++6.0) 这是用MFC基于对话写的一个应用程序中的一段代码,作用是单击一个按钮,在一个列表框里显示程序连接的数据库里的数据 请问一下每一行程序都是做什么的?能教我怎么使用这些函数就更好了.小白求教 void CtrainDlg::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code

新手-android程序,eclipse没报错,但是运行会意外停止

问题描述 android程序,eclipse没报错,但是运行会意外停止 本人刚开始学习android,跟着书写了个程序,这个程序是会有一个东西随着手指拖动而移动,编译完没有问题,但是在手机上运行的时候却是意外停止,代码和书上写的一模一样,求大神指导 DrawView.java的代码:/** * */package com.example.customview; import android.content.Context;import android.graphics.Canvas;import