c语言航班信息查询系统 程序,航班查询系统C语言源程序.doc

航班查询系统C语言源程序

#include

#include

#include

#define NOD struct plane_list

struct plane

{char number [10];

char start[10];

char arrive [10];

char date[10];

char starttime[10];

char arrivingtime[10];

char price[10];

char model[10];

};

NOD

{char number [10];

char start[10];

char arrive [10];

char date[10];

char starttime[10];

char arrivingtime[10];

char price[10];

char model[10];

NOD*next;

};

FILE *fp;

/*由文件中的数据生成一个飞机航班的链表,如果文件不存在,则是一个空链表*/

NOD *load(char planename[])

{ NOD *p,*q,*head;

struct plane per;

p=(NOD *)malloc(sizeof(NOD));

q=head=NULL;

if((fp=fopen(planename,"rb"))==NULL)

return head;

else

{ while(!feof(fp))

{ if(fread(&per,sizeof(struct plane),1,fp)==1)

{

p=(NOD *)malloc(sizeof(NOD));

strcpy(p->number,per.number);

strcpy(p->start,per.start);

strcpy(p->arrive,per.arrive);

strcpy(p->date,per.date);

strcpy(p->starttime,per.starttime);

strcpy(p->arrivingtime,per.arrivingtime);

strcpy(p->price,per.price);

strcpy(p->model,per.model);

head=p;

p->next=q;

q=head;

}

}

}

fclose(fp);

return(head);

}

/*输入*/

NOD *insert(NOD *head)

{ NOD *temp,*p;

p=head;

temp=(NOD *)malloc(sizeof(NOD));

printf("\n\t请输入航班号:");

scanf("%s",temp->number);

printf("\n\t请输入起点站:");

scanf("%s",temp->start);

printf("\n\t请输入终点站:");

scanf("%s",temp->arrive);

printf("\n\t请输入起飞时间:");

scanf("%s",temp->starttime);

printf("\n\t请输入到达时间:");

scanf("%s",temp->arrivingtime);

printf("\n\t请输入班期:");

scanf("%s",temp->date);

printf("\n\t请输入票价:");

scanf("%s",temp->price);

printf("\n\t请输入航班型号:");

scanf("%s",temp->model);

head=temp;

temp->next=p;

return head;

}

/*保存*/

void save(NOD *head, char filename[])

{NOD*p;

struct plane per;

if((fp=fopen(filename,"wb"))==NULL)

{printf(" 文件无法写入");

exit(0);

}

else

{ p=head;

while(p!=NULL)

{ strcpy(per.number,p->number);

strcpy(per.start,p->start);

strcpy(per.arrive,p->arrive);

strcpy(per.date,p->date);

strcpy(per.sta

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值