| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1773 人关注过本帖
标题:用dev-c++出现[Error] ld returned 1 exit status 是怎么回事?
只看楼主 加入收藏
fallingtcz
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2018-5-31
收藏
 问题点数:0 回复次数:0 
用dev-c++出现[Error] ld returned 1 exit status 是怎么回事?
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<malloc.h>
#define Max 2
#define price 3
typedef struct node
{
    int num;
    int reachtime;
    int leavetime;
}CarNode;
typedef struct NODE
{
    CarNode *strack[Max+1];
    int top;
}SeqStrackCar;
typedef struct car
{
    CarNode *data;
    struct car *next;
}QueueNode;
typedef struct Node
{
    QueueNode *head;
    QueueNode *rear;
}LinkQueueCar;
void InitStrack(SeqStrackCar *);
int InitQueue(LinkQueueCar *);
int Arrival(SeqStrackCar *,LinkQueueCar *);
void Leave(SeqStrackCar *,SeqStrackCar *,LinkQueueCar *);
void List(SeqStrackCar,LinkQueueCar);
void PRINT(CarNode *p);
int main()
{
    SeqStrackCar enter,temp;
    LinkQueueCar wait;
    int ch;
    InitStrack(&enter);
    InitStrack(&temp);
    InitQueue(&wait);
    printf("\n\n1.车辆到达");
    printf("\n\n2.车辆离开");
    printf("\n\n3.车辆信息");
    printf("\n\n4.退出程序");
    printf("请选择要实现的操作:");
    while(1)
    {
scanf("%d",&ch);
    printf("\n");
    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 InitStrack(SeqStrackCar *s)
{
    int i;
    s->top=0;
    for(i=0;i<=Max;i++)
    s->strack[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;
}
void PRINT(CarNode *p)
{
    int a1,a2;
    printf("\n请输入离开时间:");
    scanf("%d",&(p->leavetime));
    printf("\n离开车辆的车牌号:%d",p->num);
    printf("\n离开车辆到达时间:%d",p->reachtime);
    printf("\n离开车辆离开时间:%d",p->leavetime);
    a1=p->reachtime;
    a2=p->leavetime;
    printf("\n停车场费用:%d",(a2-a1)*price);
    free(p);
}
int Arrival(SeqStrackCar *enter,LinkQueueCar *wait)
{
    CarNode *p;
    QueueNode *t;
    p=(CarNode *)malloc(sizeof(CarNode));
    flushall();
    printf("\n请输入到达车辆车牌号:");
    scanf("%d",&(p->num));
    if(enter->top<Max)
    {
        enter->top++;
        printf("\n请输入该车辆到达时间:");
        scanf("%d",&(p->reachtime));
        enter->strack[enter->top]=p;
        return 1;
    }
    else
    printf("\n停车场已满,请在便道上等待!");
    getchar();
    t=(QueueNode *)malloc(sizeof(QueueNode));
    t->data=p;
    t->next=NULL;
    wait->rear->next=t;
    wait->rear=t;
    return 1;
}
void Leave(SeqStrackCar *enter,SeqStrackCar *temp,LinkQueueCar *wait)
{
    int room;
    CarNode *p,*t;
    QueueNode *q;
    if(enter->top>0)
    {   while(1)
    {
        printf("停车场里停放的车辆总数:%d",enter->top);
        printf("请输入要离开车辆的位置:");
        scanf("%d",&room);
        if(room>=1&&room<=enter->top)
        break;
    }
    while(enter->top>room)
    {
        temp->top++;
        temp->strack[temp->top]=enter->strack[enter->top];
        enter->strack[enter->top]=NULL;
        enter->top--;
    }
    p=enter->strack[enter->top];
    enter->strack[enter->top]=NULL;
    enter->top--;
    while(temp->top>=1)
    {
        enter->top++;
        enter->strack[enter->top]=temp->strack[temp->top];
        temp->strack[temp->top]=NULL;
        temp->top--;
    }
    PRINT(p);
    if(wait->head!=wait->rear&&enter->top<Max)
    {
        q=wait->head->next;
        t=q->data;
        enter->top++;
        printf("便道的%d号车进入第%d位置。",t->num,enter->top);
        printf("请输入现在的时间:");
        scanf("%d",&(t->reachtime));
        wait->head->next=q->next;
        if(q==wait->rear)
        wait->rear=wait->head;
        enter->strack[enter->top]=t;
        free(q);
    }
    else
    printf("便道里没有车。");
}
else
printf("停车场里没有车。");
}
void List1(SeqStrackCar *S)
{
    int i;
    if(S->top>0)
    {
        printf("车场:");
        printf("位置    到达时间    车牌号\n");
        for(i=1;i<=S->top;i++)
        {
            printf("%26d",i);
            printf("%6d",S->strack[i]->reachtime);
            printf("%10d",S->strack[i]->num);
            printf("\n");
        }
    }
    else
    printf("车场里没有车。");
}
void List2(LinkQueueCar *wait)
{
    QueueNode *p;
    p=wait->head->next;
    if(wait->head!=wait->rear)
    {
        printf("等待车辆的号码为:");
        while(p!=NULL)
        {
            printf("%10d",p->data->num);
            p=p->next;
        }
        printf("\n");   
    }
    else
    printf("便道里没有车。");
}
void List(SeqStrackCar S,LinkQueueCar wait)
{
    int flag,tag;
    flag=1;
    while(flag)
    {
        printf("请选择(1/2/3):");
        printf("1.车场       2.便道      3.返回");
        scanf("%d",&tag);
        if(tag>=1||tag<=3)
        break;
        else
        printf("请选择(1/2/3):");   
    }
    switch(tag)
    {
   
    case 1:
        List1(&S);break;
    case 2:
        List2(&wait);break;
    case 3:
        flag=0;break;
    default:
        break;
    }
}
搜索更多相关主题的帖子: int top wait printf break 
2018-05-31 16:25
快速回复:用dev-c++出现[Error] ld returned 1 exit status 是怎么回事?
数据加载中...
 
   



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

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