文档介绍:/******头文件(.h)***********/
#include "" /*I/O函数*/
#include "" /*标准库函数*/
#include ""/*字符串函数*/
#include "" /*字符操作函数*/
#include <>
#define M 50 /*定义常数表示记录数*/
typedef struct /*定义数据结构*/
{
char number[12]; /*车次*/
struct tm time; /*发车时间*/
char first[10]; /*起点站*/
char last[8]; /*终点站*/
char n_time[10]; /*行车时间*/
int max_p; /*额定人数*/
int people; /*已定人数*/
}ADDRESS;
/******以下是函数原型*******/
int enter(ADDRESS t[]); /*输入记录*/
void list(ADDRESS t[],int n); /*显示记录*/
void search_last(ADDRESS t[],int n); /*按终点站找显示记录*/
void search_number(ADDRESS t[],int n); /*按车次查找显示记录*/
int delete(ADDRESS t[],int n); /*删除记录*/
int add(ADDRESS t[],int n); /*插入记录*/
void save(ADDRESS t[],int n); /*记录保存为文件*/
void sort(ADDRESS t[],int n); /*按车次排序*/
void print(ADDRESS t[]); /*显示单条记录*/
int _last(ADDRESS t[],int n,char *s) ; /*查找函数*/
int _number(ADDRESS t[],int n,char *s) ; /*查找函数*/
int menu_select(); /*主菜单函数*/
/*买票*/
void buy(ADDRESS t[],int n)
{
char s[20]; /*保存待查找终点站字符串*/
int i,m=1; /*保存查找到结点的序号*/
time_t tval;
struct tm *now;
clrscr();/*清屏*/
tval = time(NULL);
now = localtime(&tval);
printf("待查找终点站\n");
scanf("%s",s); /*输入待查找终点站*/
getchar();
for(i=0;i<n;i++)/* 从第一条记录开始,直到最后一条*/
{
if(strcmp(s,t[i].last)==0&&t[i].people<t[i].max_p) /*记录中的车次和待比较的是否相等*/
{if(strcmp(t[i].,now->tm_hour)>0 )
printf("此班次已经发出\n");
if(strcmp(t[i].,now->tm_hour)==0 )
{if (strcmp(t[i].,now->tm_min)> 0)
printf("此班次已经发出\n");
if (strcmp(t[i].,now->tm_min)== 0)
{if(strcmp(t[i].,now->tm_sec)> 0)
printf("此班次已经发出\n");
if(strcmp(t[i].,now->tm_sec)<= 0)
t[i].people++;
}
if (strcmp(t[i].,now->tm_min)< 0)
t[i].people++;
}
if(strcmp(t[i].,now->tm_hour)<0 )
t[i].people++;
m=0;}
}
if(m==1)
printf("车票已卖完");
}
/*退票*/
void back(ADDRESS t[],int n)
{
char s[20];
int i;
time_t tval;
struct tm *now;
clrscr(); /*清屏*/
print