资源简介
火车票订票系统代码
代码片段和文件信息
#include“common.h“
PCbuy createOneCbuy(PNCustomer pc PBticket pt)
{
PCbuy pb = (PCbuy)malloc(sizeof(NCbuy));
strcpy(pb->b_cname pc->c_name);
strcpy(pb->b_sstation pt->b_sstation);
strcpy(pb->b_tstation pt->b_tstation);
pb->b_trainnu = pt->b_trainnu;
pb->b_time = pt->b_time;
pb->b_isbuy =(pt->isBuy);
pb->next = NULL;
}
PCbuy createBuylink(PCbuy phead)
{
return phead;
}
PCbuy searchCbuyByName(PNCustomer pnc PCbuy phead)
{
PCbuy ptemp = phead;
while (ptemp != NULL)
{
if (0 == strcmp(ptemp->b_cname pnc->c_name))
{
return ptemp;
}
ptemp = ptemp->next;
}
return ptemp;
}
PCbuy delOneCbuy(PCbuy phead PCbuy pdel)
{
PCbuy pri = phead;
if (phead == pdel)
{
phead = pdel->next;
free(phead);
}
else
{
while (pri != NULL && pri->next != pdel)
{
pri = pri->next;
}
pri->next = pdel->next;
free(pdel);
}
return phead;
}
PCbuy insertBuylink(PCbuy phead PCbuy pnew)
{
PCbuy ptemp = NULL;
PCbuy ptail = NULL;
// 链表中没有数据,第一次创建链表
// 链表中只有一条数据
if (phead->next == NULL)
{
phead->next = pnew;
return phead;
}
else
{
while(ptemp->next != NULL)
{
ptemp = ptemp->next;
}
ptemp->next = pnew;
return phead;
}
}
void traverseBuylink(PCbuy phead)
{
PCbuy ptemp = phead;
int i = 0;
while (ptemp != NULL)
{
printf(“用户名=%s “ ptemp->b_cname);
printf(“起始站=%s “ ptemp->b_sstation);
printf(“终点站=%s “ ptemp->b_tstation);
printf(“车次=%d “ ptemp->b_trainnu);
printf(“达到时间=%d“ ptemp->b_time);
printf(“\n“);
ptemp = ptemp->next;
}
}
void printOneCbuy(PCbuy ptemp)
{
printf(“用户名=%s “ ptemp->b_cname);
printf(“起始站=%s “ ptemp->b_sstation);
printf(“终点站=%s “ ptemp->b_tstation);
printf(“车次=%d “ ptemp->b_trainnu);
printf(“达到时间=%d“ ptemp->b_time);
printf(“\n“);
}
int judgeHadBuy(PCbuy phead PNCustomer pc)
{
PCbuy ptemp = phead;
while (ptemp != NULL)
{
if (0 == strcmp(ptemp->b_cname pc->c_name))
{
return FAILURE;
}
ptemp = ptemp->next;
}
return SUCCESS;
}
PCbuy readAllPCbuy()
{
PCbuy phead = NULL;
PCbuy ptemp = NULL;
PCbuy ptail = NULL;
FILE *f = NULL;
f = fopen(CBUY_DB “r+“);
phead = (PCbuy)malloc(sizeof(NCbuy));
ptail = phead;
int size = fread(phead sizeof(NCbuy) 1 f);
while (size)
{
ptemp = (PCbuy)malloc(sizeof(NCbuy));
size = fread(ptemp sizeof(NCbuy) 1 f);
if (size != 1)
{
free(ptemp);
break;
}
ptail->next = ptemp;
ptail = ptemp;
}
fclose(f);
return phead;
}
void writeAllPCbuy(PCbuy phead)
{
PCbuy ptemp = phead;
FILE *f = NULL;
f = fopen(CBUY_DB “w+“);
while (ptemp != NULL)
{
fwrite(ptemp sizeof(NCbuy) 1 f);
ptemp = ptemp->next;
}
fclose(f);
}
PQueue createQueue(PCbuy pcb int num)
{
PQueue phead = (PQueue)malloc(sizeof(NQueue));
phead->number = num;
phead->isUbook = 0;
phead->pfront = pcb;
return phead;
}
PQueue isQueueExist(PQueue* p int num int arr_size int *pos)
{
int i = 0;
for (i = 0; i < arr_size; i++)
{
if (p[i
- 上一篇:敏感词过滤+最新敏感词库
- 下一篇:计算机专业英语口语学习资料
相关资源
- Micrium.RTOS.1.0.0.pack
- ISE_14.7_license.lic
- stm32f103c8t6 4 oled.rar
- mpu6050+hmc5883L.rar
- 嵌入式图形界面MiniGUI的示例程序9例
- MP3文件ID3v2ID3v2APEv2标签读取
- 课程作业:模拟仓库管理系统
- ARM嵌入式项目实战
- 一个简单实用个人日记管理系统
- 带时间温度显示的室内灯光控制系统
- 成绩管理系统(数据结构)
- uCOS编译环境建立 BC45 TASM
- FIR低通滤波器 ccs运行环境
- stm32 用SPI 方式读写 SDHC
- 自动售货机的内部嵌入式系统
- 51单片机中使用ucos ii的优缺点
- 嵌入式实时操作系统ucos-II 第二版 源
- 基于串口设备的嵌入式Web服务器系统
- 基于LW IP的嵌入式串口服务器的设计与
- 一种嵌入式串口共享服务器的设计
- 21天学会嵌入式开发STM32.zip
- 嵌入式智能平台为城市一卡通打造智
- 研祥“EVOC”嵌入式智能平台在
- ARM7TDMI-S在嵌入式系统中的Bootloader代码
- LPC2000系列微控制器应对嵌入式需求
- 嵌入式实时操作系统μC/OS-II与eCos的
- 基于STM32的嵌入式双目图像采集系统设
- 嵌入式实时操作系统在DATU中的应用
- 嵌入式实时操作系统μC/OS-II下通用驱
- 嵌入式实时操作系统μC/OS-II在ARM上的
评论
共有 条评论