Clfye 2018-12-27 23:45 采纳率: 0%
浏览 545

求助~~C++数据结构 一个简单的系统

求dalao看看我这个功能1系统哪里出问题了 (报错)
真.萌新

```--------------------Configuration: 1 - Win32 Debug--------------------
--------------------Configuration: 1 - Win32 Debug--------------------
Compiling...
1.cpp
C:\Users\16926\Desktop\vc6.0data\课余\text\1.cpp(104) : error C2065: 'strcmp' : undeclared identifier
C:\Users\16926\Desktop\vc6.0data\课余\text\1.cpp(162) : error C2065: 'display_line' : undeclared identifier
执行 cl.exe 时出错.

1.obj - 1 error(s), 0 warning(s)


#include <stdio.h>
#include <stdlib.h>
#define MAX 1024
//客户信息
typedef struct Custom           
{
    char name[12];          //客户姓名
    char sex[3];            //客户性别
    char phonenumber[20];   //客户手机号码
    char idcard[20];        //客户身份证号码
    int num;                //客户选择的机次号
    struct Custom *next;    //下一个结点
} Custom;

//头结点
typedef struct Customhead
{
    int count;
    Custom *next;
} Customhead;

//航班信息
typedef struct airline
{
    char line_num;      //航班号
    char start_place[20];   //起飞地
    char end_place[20];     //目的地
    char time1[10];         //起飞时间
    char time2[10];         //降落时间
    int total;              //总座位数
    int left;               //剩余座位数
    struct airline *next;   //下一个结点
} airline;

//头结点
typedef struct airlinehead
{
    int count;
    airline *next;
} airlinehead;


airlinehead* import(int n,airlinehead *pheadline)           //录入航班
{
    airline *temp = new airline;
    temp->next=NULL;
    pheadline->next=temp;
    pheadline->count = n;
    for(int i=1; i<n; i++)
    {
        printf("请输入%d个航班号:",i);
        scanf("%s",&temp->line_num);
        printf("请输入%d个航班的起飞地:",i);
        scanf("%s",&temp->start_place);
        printf("请输入%d个航班的目的地:",i);
        scanf("%s",&temp->start_place);
        printf("请输入%d个航班的起飞时间:",i);
        scanf("%s",&temp->time1);
        printf("请输入%d个航班的降落时间:",i);
        scanf("%s",&temp->time2);
        printf("请输入%d个航班的总座位数:",i);
        scanf("%s",&temp->total);
        if(i<n-2)
        {
            temp->next = new airline;
            if(temp->next == NULL)
            {
                printf("分配内存失败\n");
                exit(1);
            }
            temp->next->next=NULL;
            temp = temp->next;
        }
    }
}
airline* query(airlinehead *phead)      //查询航班信息
{
    int choose;
    airline *find=NULL;
    airline *temp;
            printf("=============查询=============\n");
            printf("* * * * 1按航班号查询* * * * \n");
            printf("* * * * 2按起飞地查询* * * * \n");
            printf("=============================\n");
            printf("请选择:");
                scanf("%d",&choose);
                    switch(choose)
                    {
                            case 1:
                                char line_num[10];
                                    printf("请输入航班号:");
                        scanf("%s",&line_num);
                        temp=phead->next;
                        while (temp)
                        {
                            if(strcmp(temp->line_num,line_num) == 0)
                            {
                                find=temp;
                                return temp;
                                break;
                            }
                            else
                            {
                                temp = temp->next;
                            }
                        }
                        if(!temp)
                            {
                                printf("没有找到航班信息。");
                                return NULL;
                            }
                        break;
                    }
}
int main ()
{
airlinehead *headline=new airlinehead;
headline->count=0;
headline->next=NULL;
    int select;
    int air_number;
    int n=0;
a:
    system("cls");
printf("\t|******************************************|\n");
printf("\t|* * * * * * * * 1.录入航班* * * * * * * * |\n");
printf("\t|* * * * * * * * 2.查询航班* * * * * * * * |\n");
printf("\t|* * * * * * * * 3.订票* * * * * * * * * * |\n");
printf("\t|* * * * * * * * 4.退票* * * * * * * * * * |\n");
printf("\t|* * * * * * * * 5.退出程序* * * * * * * * |\n");
printf("\t|******************************************|\n");
printf("请选择所需的服务;\n");
scanf("%d",&select);
switch(select)
        {
        case 1:
             int num;
            printf("请选择您要录入的航班的数目: ");
            scanf("%d",&num);
            printf("\n");
            import(num,headline);
            printf("\n");
                                    //display_all_line(headline);
            printf("航班信息成功录入。。");
            printf("\n\n");
            break;

        case 2:
                airline *find;
                find=query(headline);
                if(find)
                {
                    display_line(find);
                }
                printf("按任意键返回.........\n");
                getchar();
               break;
        case 3:
                printf("按任意键返回.........\n");
                getchar();
               break;
        case 4:
                printf("按任意键返回.........\n");
                getchar();
               break;
        case 5:exit(0);
        }

return 0;
}
  • 写回答

1条回答

  • threenewbee 2018-12-27 15:49
    关注

    scanf("%c%c%c%c%d",&L.air[n].line_num,&L.air[n].start_place,&L.air[n].end_place,&L.air[n].time1,&L.air[n].time2);
    你这么输入,航班号只能是单个字符
    要是字符串,你需要用%s,而不是%c

    评论

报告相同问题?

悬赏问题

  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题