「已注销」 2021-07-05 12:38 采纳率: 100%
浏览 8
已采纳

这个程序中为什么不能运行,怎么改,p->date=getSIgnal是什么意思

  • #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
    typedef struct Information
    {
    char Name[10];
    int KB;//开放表示为0,不开放表示为1;
    float Pos;//位置根据平面图拟定;
    int Type;//信号机性质,列车信号取1,调车信号取0;
    struct date;
    struct Information*next,*front;//前一信号机指针,后一信号机指针;
    }Signal,*pSignal;
    //创建双链表
    pSignal createDlist(pSignal head)
    {
    if(head==NULL)
    {
      head=(pSignal)malloc(sizeof(Information));
      head->front=NULL;//将*head的后继赋值为空; 
      head->next=NULL;//将*head的前驱赋值为空; 
    
    }
    return head;
    
    }
    Information getSignal()//将所需要的数据传给信息链表
    {
    Information information;
    printf("\t信号机名称:");
    scanf("\t%s",&information.Name);
    printf("\t信号机开放状态:");
    scanf("\t%d",&information.KB);
    printf("\t信号机地址:");
    scanf("\t%f",&information.Pos);
    printf("\t闭锁继电器状态:");
    scanf("\t%d",&information.Type);
    return information;
    }
    //插入信息
    pSignal insertSignal(pSignal head)
    {
    if(head==NULL)
    {
      head=createDlist(head);
    
    }
    pSignal p=(pSignal)malloc(sizeof(struct Information));
    p->date
  • =getSignal();
    if(head->next==NULL)
    {
      p->next=head->next;
      head->next=p;
      p->front=head;
      return head;
    
    }
    p->next=head->next;
    head->next->front=p;//将p赋值给p->next的后继;
    head->next=p;
    p->front=head;
    return head;
    }
    //删除信息
    void delete_xinhaoji(pSignal head)
    {
    char Signal_num[20];
    printf("\t请输入要删除的信号机的名称:");
    scanf("%s",Signal_num);
    pSignal temp;
    for(temp=head->next;temp!=NULL;temp=temp->next)
    {
      if(strcmp(temp->Name,Signal_num)==0)
      {
          // 找到需要删除节点的位置
          pSignal front=temp->front;
          pSignal next=temp->next;
          //进行删除操作; 
          front->next=next;
          next->front=front; 
          free(temp);//释放temp所占用的内存; 
          printf("\t\t\t删除信号机成功!\n");
          return ;
      }
    
    }
    if(temp==NULL)
    {
      printf("\t无此信号机!\n");
    
    }
    }
    int main()
    { pSignal head=NULL;//让Signal的头指针为空指针;
    head=createDlist(head);
    insertSignal(head);
    insertSignal(head);
    insertSignal(head);
    insertSignal(head);//调用四次insert函数,插入四组数据;
    delete_xinhaoji(head);//调用delete函数;
    printf("\t");
    system("Pause");
    return 0;
    }

4.
5.

-

  • 写回答

2条回答 默认 最新

  • CSDN专家-link 2021-07-05 13:04
    关注

    p->date=getSIgnal肯定是错的,两遍类型不一致

    void getSignal(Signal *s)//将所需要的数据传给信息链表
    {
    printf("\t信号机名称:");
    scanf("\t%s",s->Name);
    printf("\t信号机开放状态:");
    scanf("\t%d",&s->KB);
    printf("\t信号机地址:");
    scanf("\t%f",&s->Pos);
    printf("\t闭锁继电器状态:");
    scanf("\t%d",&s->Type);
    }
    
    //插入信息
    pSignal insertSignal(pSignal head)
    {
    if(head==NULL)
    {
      head=createDlist(head);
    }
    pSignal p=(pSignal)malloc(sizeof(struct Information));
    getSignal(p);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题