以下是系统部分页面
以下是部分源码,需要源码的私信
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define max_user 100
typedef struct ft
{
char name[50];//名字
char start_place[50];//出发地
char end_place[50];//目的地
char date[50];//发车日期
char flight_time[50];//运行时间
int ticket_price;//票价
int total;//总票数
int surplus;//剩余票数
ft* next;
}flight;
flight L;//创建头结点
typedef struct us//用户使用
{
char name[50];
char id[50];
char phone[20];
char flight_name[50];//车次信息
int flighr_price;//价钱
}User;//用户信息
User UL[max_user];//创建头结点
int count_user = 0;
int choose_()//定义选择函数——后期只需要进行调用就行--不需要重复写
{
while (1)
{
printf("请输入你的选择:");
int c;
scanf("%d", &c);
printf("\n");
if (c == 1)
{
return 1;
}
else if (c == 2)
{
return 2;
}
else if (c == 3)
{
return 3;
}
else if (c == 0)
{
return 0;
}
else if (c == 4)
{
return 4;
}
else if (c == 5)
{
return 5;
}
else if (c == 6)
{
return 6;
}
else if (c == 7)
{
return 7;
}
else
{
printf("输入错误,请重新输入\n");
}
}
}
int InitList_flight()//初始化航班信息
{
L.next = NULL;
FILE* fp = fopen("./flight.txt", "r");
if (!fp)
{
printf("打开文件失败\n");
return 0;
}
flight* p = &L;
flight* q;
q = (flight*)malloc(sizeof(flight));
if (!q)
{
printf("q--malloc失败\n");
return 0;
}
while (fscanf(fp, "%s%s%s%s%s%d%d%d", q->name, q->start_place, q->end_place, q->date, q->flight_time, &q->ticket_price, &q->total, &q->surplus) != EOF)
{
p->next = q;
p = q;
q = (flight*)malloc(sizeof(flight));
if (!q)
{
printf("q--malloc失败\n");
return 0;
}
}
p->next = NULL;
fclose(fp);
return 0;
}
int Updata_flight()//用来更新航班信息
{
FILE* fp = fopen("./flight.txt", "w+");
if (!fp)
{
printf("打开文件失败\n");
return 0;
}
flight* q = L.next;
while (q != NULL)
{
fprintf(fp, "%s %s %s %s %s %d %d %d\n", q->name, q->start_place, q->end_place, q->date, q->flight_time, q->ticket_price, q->total, q->surplus);
q = q->next;
}
fclose(fp);
return 0;
}
int Add_flight()
{
flight* p = L.next;
flight* q;
q = (flight*)malloc(sizeof(flight));
if (!q)
{
printf("q--malloc失败\n");
return 0;
}
printf("******************航班信息录入*****************\n");
printf("请输入航班名称:");
scanf("%s", q->name);
printf("请输入出发地:");
scanf("%s", q->start_place);
printf("请输入目的地:");
scanf("%s", q->end_place);
printf("请输入发车日期:");
scanf("%s", q->date);
printf("请输入运行时间:");
scanf("%s", q->flight_time);
printf("请输入票价:");
scanf("%d", &q->ticket_price);
printf("请输入总票数:");
scanf("%d", &q->total);
q->surplus = q->total;
L.next = q;
q->next = p;
Updata_flight();
printf("添加成功\n");
return 0;
}
int modifiction_flight()
{
printf("请输入你想修改的航班名称:");
char name[50];
scanf("%s", name);
flight* q = L.next;
while (q != NULL)
{
if (strcmp(name, q->name) == 0)//找到该航班
{
printf("******************信息修改******************\n");
printf("请输入航班名称:");
scanf("%s", q->name);
printf("请输入出发地:");
scanf("%s", q->start_place);
printf("请输入目的地:");
scanf("%s", q->end_place);
printf("请输入发车日期:");
scanf("%s", q->date);
printf("请输入运行时间:");
scanf("%s", q->flight_time);
printf("请输入票价:");
scanf("%d", &q->ticket_price);
printf("请输入总票数:");
scanf("%d", &q->total);
printf("请输入剩余票数:");
scanf("%d", &q->surplus);
Updata_flight();
printf("修改成功\n");
return 0;
}
q = q->next;
}
printf("未找到该航班\n");
return 0;
}