资源简介
火车票订票系统代码
代码片段和文件信息
#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
- 上一篇:敏感词过滤+最新敏感词库
- 下一篇:计算机专业英语口语学习资料
相关资源
- 使用多线程技术,模拟通过四个窗口
- 嵌入式作业
- 嵌入式工程师面试笔试资料整合
- 嵌入式视频教程.txt
- dos和bios开发讲解.pdf
- 申嵌视频嵌入式
- 嵌入式 WinCE 专用 Newtonsoft.Json.dll 亲测
- 从文件中读取矩阵,并实现转置
- 作业调度算法中文
- 大学课程中相关一些算法题
-
Qt/em
bedded的嵌入式导航电子地图实 - VC 绘图库VCGraph-V20091123
- 基于单片机的体温呼吸检测系统设计
- 串口通信verilog代码
- 嵌入式课程设计QT完美实现任意进制运
- FTD2XX.dll和oflash.exe
- 数据结构大作业
- DSP最小系统的设计
- VC嵌入式CLips专家系统实现战场环境的
- t9Input-stm32
- 利用栈实现括号匹配的检验
- 数据结构--员工管理系统
- 数据结构——图论
- 嵌入式软件开发面试题整理
- 嵌入式工程师面试宝典
- 杭电嵌入式第一批考试题目答案
- 嵌入式系统原理与接口技术
- 基于8255a的计算器
- 3个ARM嵌入式编程的,我的结课作业,
- 单片机和LCD1602实现的简易计算器
评论
共有 条评论