⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 train_booking_interact.c

📁 火车定标系统...用VC编译通过的
💻 C
字号:
//	train_booking_interact.c -- 包含查询、报表等交互操作函数
//
/////////////////////////////////////////////////////////////////////////////

#ifndef TRAIN_BOOKING_INTERACT_C_
#define TRAIN_BOOKING_INTERACT_C_

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>

#include "train_booking_declare.h"
#include "train_booking_const.h"
#include "train_booking_unit.h"

/////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////
// 函数功能:	按起始站/终点站搜索车次
//
// 函数参数:	system_info_pt:系统信息体指针
//				ok_sq_head:查询结果链表头结点指针
//				count:反回搜索结果数量
//				type:搜索类型:1为起始站,0为终点站
//
/////////////////////////////////////////////////////////////////////////////
status search_train_sq_by_start_end(system_info *system_info_pt,
								train_sq_info *ok_train_sq_head, char type)
{
	train_sq_info *train_sq_info_pt, *train_sq_info_head;
	char t_station[128], call[16], t_target_station[16];
	int count, search_state;
	train_info *train_info_pt;

	CLS;
	actitle("按起始站/终点站搜索车次");

	if (1 == type)			// 取得称呼
	{
		strcpy(call, "起始站");
	}
	else
	{
		strcpy(call, "终点站");
	}

	if (!(get_str(call, t_station, MIN_TRING_ID_LEN, MAX_TRAIN_ID_LEN)))
	{
		message(WARN, "搜索车次失败!", WC);

		return FAIL;
	}

	printf("【信息】正在搜索%s为(%s)的所有车次信息...\n", call, t_station);

	count = 0;		// 清空计数器
	train_sq_info_head = &system_info_pt->train_sq_list;	// 取得链头

	if (!train_sq_info_head->next)
	{
		message(ERROR, "本车站都还没有车次!", NULL);
		message(WARN, "查找车次失败!", WC);

		return FAIL;
	}

	while (train_sq_info_head->next)
	{
		train_sq_info_head = train_sq_info_head->next;		// 跳过头结点
		train_info_pt = train_sq_info_head->train_list.next;	// 取得其中一趟火车信息即可

		if (1 == type)
		{
			strcpy(t_target_station, train_info_pt->start);
		}
		else
		{
			strcpy(t_target_station, train_info_pt->final);		// 取得对应站点名称
		}

		if (check_string(t_target_station, t_station))			// 查找到符合条件的车次
		{
			if (!(train_sq_info_pt = (train_sq_info *)malloc(sizeof(train_sq_info))))
			{
				message(ERROR, "搜索车次信息时申请内存失败!", NULL);
				message(WARN, "查找车次失败!", WC);

				return FAIL;
			}

			// 获取匹配数据,链上表尾	
			ok_train_sq_head->next = train_sq_info_pt;		// 链上表尾
			*train_sq_info_pt = *train_sq_info_head;			// 数据赋给新链表
			train_sq_info_head->next = NULL;					// 封尾
			ok_train_sq_head = ok_train_sq_head->next;			// 
			count++;
		}
	}

	if (!count)		// 没有找到匹配结果 
	{
		printf("【信息】没有找到任何%s为(%s)的车次信息!\n", call, t_station);
		message(TIP, "按任意键返回", WC);

		return FAIL;
	}
	else
	{
		printf("【信息】搜索完成!共找到%d个符合您的要求的车次。\n", count);
		message(TIP, "按任意键始可查看结果!", W);

		show_sq_links(ok_train_sq_head, 1);		// 显示结果
		message(INFO, "按任意键返回主界面!", WC);
	}
	
	return OK;
}



/////////////////////////////////////////////////////////////////////////////
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -