|
|
|
@ -1,113 +1,59 @@
|
|
|
|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#define fout "%d %s %s %s %d %d %d "
|
|
|
|
|
FILE *fp;
|
|
|
|
|
struct car
|
|
|
|
|
{
|
|
|
|
|
char cost[10]; //班次
|
|
|
|
|
char carnumber[10]; //车号
|
|
|
|
|
char people[5]; //最大载客数
|
|
|
|
|
char start[50]; //起点
|
|
|
|
|
char starttime[30]; //出发时间
|
|
|
|
|
char finish[50]; //终点
|
|
|
|
|
char finishtime[30]; //到达时间
|
|
|
|
|
char money[5]; //票价
|
|
|
|
|
char man[3]; //订票人数
|
|
|
|
|
struct car *next;
|
|
|
|
|
};
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <time.h> //时间库函数
|
|
|
|
|
#include <conio.h> //输入输出库
|
|
|
|
|
|
|
|
|
|
struct passenger
|
|
|
|
|
{
|
|
|
|
|
char numbers[10]; //班次
|
|
|
|
|
char id[20]; //身份证号码
|
|
|
|
|
char name[50]; //姓名
|
|
|
|
|
char ticket[2]; //订票数
|
|
|
|
|
char snum[2]; //座位号
|
|
|
|
|
struct car *next;
|
|
|
|
|
};
|
|
|
|
|
int class_num = 0; //初始班次总数为0
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
typedef struct car
|
|
|
|
|
{
|
|
|
|
|
void menu();
|
|
|
|
|
void Exit();
|
|
|
|
|
void Buy();
|
|
|
|
|
void Refund();
|
|
|
|
|
void Query();
|
|
|
|
|
void Exploer();
|
|
|
|
|
void Insert();
|
|
|
|
|
void PrintTable();
|
|
|
|
|
menu();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
char number[10]; //车次编号
|
|
|
|
|
char hour[3]; //时间,,小时
|
|
|
|
|
char min[3]; //分钟
|
|
|
|
|
char from[10]; //起始站
|
|
|
|
|
char to[10]; //终点站
|
|
|
|
|
float hours; //车程实际时间
|
|
|
|
|
int max; //最大车载容量
|
|
|
|
|
int bought; //已售票数
|
|
|
|
|
} CLASS;
|
|
|
|
|
|
|
|
|
|
void Exit()
|
|
|
|
|
{
|
|
|
|
|
printf("正在保存中,请稍后");
|
|
|
|
|
}
|
|
|
|
|
CLASS records[1000]; // 可记录1000车次
|
|
|
|
|
void Menu();
|
|
|
|
|
void Import();
|
|
|
|
|
void Exit();
|
|
|
|
|
void Buy();
|
|
|
|
|
void Refund();
|
|
|
|
|
void Query();
|
|
|
|
|
void Exploer();
|
|
|
|
|
void Insert();
|
|
|
|
|
void ShowTableHead();
|
|
|
|
|
void ShowTableFoot();
|
|
|
|
|
void Find(char s1[], char s2[]);
|
|
|
|
|
|
|
|
|
|
void Buy()
|
|
|
|
|
{
|
|
|
|
|
printf("");
|
|
|
|
|
}
|
|
|
|
|
void Refund()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
void Query()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
void Exploer()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
void Insert()
|
|
|
|
|
{
|
|
|
|
|
fp = fopen("car.txt", "a+");
|
|
|
|
|
car *head, *p1, *p2;
|
|
|
|
|
head = NULL;
|
|
|
|
|
p1 = new (car);
|
|
|
|
|
p2 = p1;
|
|
|
|
|
printf(">>>>>请输入对应的信息:\n");
|
|
|
|
|
printf(" 行车时间: ");
|
|
|
|
|
scanf("%s", &p1->cost);
|
|
|
|
|
printf(" 车号: ");
|
|
|
|
|
scanf("%s", &p1->carnumber);
|
|
|
|
|
printf("最大载客数: ");
|
|
|
|
|
scanf("%s", &p1->people);
|
|
|
|
|
printf(" 起点: ");
|
|
|
|
|
scanf("%s", &p1->start);
|
|
|
|
|
printf(" 出发时间(英文状态下输入): ");
|
|
|
|
|
scanf("%s", &p1->starttime);
|
|
|
|
|
printf(" 终点: ");
|
|
|
|
|
scanf("%s", &p1->finish);
|
|
|
|
|
printf(" 到达时间(英文状态下输入): ");
|
|
|
|
|
scanf("%s", &p1->finishtime);
|
|
|
|
|
printf(" 票价: ");
|
|
|
|
|
scanf("%s", &p1->money);
|
|
|
|
|
fprintf(fp,"%s %s %s %s %s %s %s %s 0 \n",p1->cost,p1->carnumber,p1->people , p1->start,p1->starttime,p1->finish,p1->finishtime,p1->money);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
delete head, p1, p2;
|
|
|
|
|
printf("数据保存中,请稍后\n");
|
|
|
|
|
}
|
|
|
|
|
void PrintTable()
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
int Number = 0, Hour = 0, Busload = 0, Bought = 0;
|
|
|
|
|
char Time[128] = "未知", Start[128] = "未知", End[128] = "未知";
|
|
|
|
|
fp = fopen("sql.txt", "r");
|
|
|
|
|
fscanf(fp, fout, &Number, &Time, &Start, &End, &Hour, &Busload, &Bought);
|
|
|
|
|
printf("班次 发车时间 起点站 终点站 行车时间 额定载量 已订票人数\n");
|
|
|
|
|
printf(fout, Number, Time, Start, End, Hour, Busload, Bought);
|
|
|
|
|
printf("\n");
|
|
|
|
|
fclose(fp);
|
|
|
|
|
Menu();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
void menu()
|
|
|
|
|
|
|
|
|
|
void Menu()
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
time_t rawtime; //获取系统时间函数
|
|
|
|
|
struct tm *timeinfo;
|
|
|
|
|
time(&rawtime);
|
|
|
|
|
timeinfo = localtime(&rawtime);
|
|
|
|
|
printf("系统当前时间:%d:%d\n", timeinfo->tm_hour, timeinfo->tm_min);
|
|
|
|
|
int InputNumber;
|
|
|
|
|
printf("/* 当前班次信息: */\n");
|
|
|
|
|
PrintTable();
|
|
|
|
|
printf("/* 1、购票 */\n");
|
|
|
|
|
printf("/* 2、退票 */\n");
|
|
|
|
|
printf("/* 3、查询路线 */\n");
|
|
|
|
|
printf("/* 4、浏览所有班次 */\n");
|
|
|
|
|
printf("/* 5、录入班次信息 */\n");
|
|
|
|
|
printf("/* 5、增加班次信息 */\n");
|
|
|
|
|
printf("/* 6、录入班次信息(首次使用) */\n");
|
|
|
|
|
printf("/* 0、退出 */\n");
|
|
|
|
|
printf("请输入相应功能选项:");
|
|
|
|
|
scanf("%d", &InputNumber);
|
|
|
|
@ -116,32 +62,384 @@ void menu()
|
|
|
|
|
switch (InputNumber)
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
printf("请输入正确的数字标号\n");
|
|
|
|
|
menu();
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("请输入正确选项!!\n");
|
|
|
|
|
system("pause");
|
|
|
|
|
Menu();
|
|
|
|
|
break;
|
|
|
|
|
case 0:
|
|
|
|
|
Exit();
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
Buy();
|
|
|
|
|
menu();
|
|
|
|
|
Menu();
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
Refund();
|
|
|
|
|
menu();
|
|
|
|
|
Menu();
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
Query();
|
|
|
|
|
menu();
|
|
|
|
|
Menu();
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
Exploer();
|
|
|
|
|
menu();
|
|
|
|
|
Menu();
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
Insert();
|
|
|
|
|
menu();
|
|
|
|
|
Menu();
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
Import();
|
|
|
|
|
Menu();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} while (InputNumber != 0);
|
|
|
|
|
}
|
|
|
|
|
void Scanf(int i, int j) // 用户用来输入班次
|
|
|
|
|
{
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
printf("请输入发车时间(xx xx)");
|
|
|
|
|
scanf("%s%s", records[i].hour, records[i].min);
|
|
|
|
|
if ((atoi(records[i].hour) < 24 && atoi(records[i].hour) >= 0) && (atoi(records[i].min) < 60 && atoi(records[i].min) >= 0))
|
|
|
|
|
break;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("输入错误!\n");
|
|
|
|
|
_getch(); //使达到按下任意键返回的作用 在新版c标准中要使用_getch();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("请输入起点站:\n");
|
|
|
|
|
scanf("%s", records[i].from);
|
|
|
|
|
printf("请输入终点站:\n");
|
|
|
|
|
scanf("%s", records[i].to);
|
|
|
|
|
printf("请输入行车时间:\n");
|
|
|
|
|
scanf("%f", &records[i].hours);
|
|
|
|
|
printf("请输入额定载量:\n");
|
|
|
|
|
scanf("%d", &records[i].max);
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
|
|
|
|
printf("请输入已售票数:\n");
|
|
|
|
|
scanf("%d", &records[i].bought);
|
|
|
|
|
if (records[i].bought <= records[i].max)
|
|
|
|
|
break;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("输入错误!\n");
|
|
|
|
|
_getch();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void Save() //文件保存函数
|
|
|
|
|
{
|
|
|
|
|
FILE *fp1, *fp2; //文件指针
|
|
|
|
|
if ((fp1 = fopen("sql.txt", "wb")) == NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("车次数据文件不存在\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
if ((fp2 = fopen("num.txt", "wb")) == NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("车次序号数据文件不存在\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
printf("数据保存中,请稍后\n");
|
|
|
|
|
fwrite(&class_num, sizeof(int), 1, fp2); //写入文件信息
|
|
|
|
|
fwrite(records, sizeof(CLASS), class_num, fp1);
|
|
|
|
|
fclose(fp1);
|
|
|
|
|
fclose(fp2); ///关闭文件
|
|
|
|
|
}
|
|
|
|
|
void Load() //加载数据文件
|
|
|
|
|
{
|
|
|
|
|
FILE *fp1, *fp2;
|
|
|
|
|
if ((fp1 = fopen("sql.txt", "rb+")) == NULL)
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("车次数据文件不存在\n");
|
|
|
|
|
_getch();
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
if ((fp2 = fopen("num.txt", "rb+")) == NULL)
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("车次序号数据文件不存在\n");
|
|
|
|
|
_getch();
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
fread(&class_num, sizeof(int), 1, fp2); //读入信息
|
|
|
|
|
fread(records, sizeof(CLASS), class_num, fp1); //读入信息
|
|
|
|
|
fclose(fp1);
|
|
|
|
|
fclose(fp2);
|
|
|
|
|
}
|
|
|
|
|
int Judge(int i) //判断时间是否超出函数***
|
|
|
|
|
{
|
|
|
|
|
struct tm *local; //时间结构体
|
|
|
|
|
time_t t; //把当前时间给t
|
|
|
|
|
t = time(NULL); //NULL在stdio.h中定义为0
|
|
|
|
|
local = localtime(&t); /////获取当前系统时间
|
|
|
|
|
if (local->tm_hour < atoi(records[i].hour) || local->tm_hour == atoi(records[i].hour) && local->tm_min < atoi(records[i].min))
|
|
|
|
|
//atoi将字符串转换成一个整数值
|
|
|
|
|
return 1;
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
int FindCarByNum(char s1[]) //查找班次
|
|
|
|
|
{
|
|
|
|
|
int i, h = 0;
|
|
|
|
|
ShowTableHead();
|
|
|
|
|
for (i = 0; i < class_num; i++)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp(s1, records[i].number) == 0) //判断字符串比较是否相等,如果符合则输出车次等信息
|
|
|
|
|
{
|
|
|
|
|
printf("|----------|----------|----------|----------|--------|--------|--------|\n");
|
|
|
|
|
printf("|%10s|%5s:%-4s|%10s|%10s|%8.1f|%8d|%8d|", records[i].number, records[i].hour,
|
|
|
|
|
records[i].min, records[i].from, records[i].to, records[i].hours, records[i].max, records[i].bought);
|
|
|
|
|
h += 2;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ShowTableFoot();
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
void Import()
|
|
|
|
|
{
|
|
|
|
|
int i = 0, j = 5, h; ////
|
|
|
|
|
char s[5];
|
|
|
|
|
FILE *fp; ////定义文件型指针变量
|
|
|
|
|
system("cls");
|
|
|
|
|
if ((fp = fopen("num.txt", "rb")) != NULL) //fopen打开文件
|
|
|
|
|
{
|
|
|
|
|
printf("车次信息已经存在,请选择添加车次功能!\n");
|
|
|
|
|
printf("按下任意键,返回主菜单\n");
|
|
|
|
|
_getch();
|
|
|
|
|
i = 1; //通过是1
|
|
|
|
|
}
|
|
|
|
|
if (i == 0)
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("请输入要录入班次总数:\n");
|
|
|
|
|
scanf("%d", &class_num); //指向班次指针
|
|
|
|
|
system("cls");
|
|
|
|
|
for (i = 0; i < class_num; i++)
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("请输入第%d个班次信息:\n", i + 1);
|
|
|
|
|
h = -1;
|
|
|
|
|
for (; h != i;) ///循环输出
|
|
|
|
|
{
|
|
|
|
|
printf("请输入班次:\n");
|
|
|
|
|
scanf("%s", records[i].number);
|
|
|
|
|
for (h = 0; h < i; h++)
|
|
|
|
|
if (strcmp(records[h].number, records[i].number) == 0)
|
|
|
|
|
//判断字符串比较是否相等,, 待比较的字符串
|
|
|
|
|
{
|
|
|
|
|
printf("输入错误!该班次已存在!\n");
|
|
|
|
|
break; ///返回
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Scanf(i, j);
|
|
|
|
|
j = 5;
|
|
|
|
|
}
|
|
|
|
|
Save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void Exit()
|
|
|
|
|
{
|
|
|
|
|
printf("感谢您的使用!!!");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
void Buy()
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
char num[10];
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("1. 售票\n");
|
|
|
|
|
printf("2. 返回\n");
|
|
|
|
|
printf("请选择(1-2):\n");
|
|
|
|
|
scanf("%d", &i);
|
|
|
|
|
if (i == 1)
|
|
|
|
|
{
|
|
|
|
|
Load();
|
|
|
|
|
Query();
|
|
|
|
|
printf("请输入要订票的班次(若无请输入0):\n");
|
|
|
|
|
scanf("%s", num);
|
|
|
|
|
for (i = 0; i < class_num; i++)
|
|
|
|
|
if (strcmp(num, records[i].number) == 0) //判断字符串是否相等
|
|
|
|
|
if (records[i].max > records[i].bought && Judge(i) == 1)
|
|
|
|
|
//判断时间是否超出当前系统时间并且已售车票没超出最大客量
|
|
|
|
|
{
|
|
|
|
|
records[i].bought++;
|
|
|
|
|
printf("通向%s班次为%s的票订票成功!\n", records[i].to, records[i].number);
|
|
|
|
|
Save();
|
|
|
|
|
_getch();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("该班次已满或已发出!\n");
|
|
|
|
|
_getch();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void Refund()
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
char num[10];
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("1. 退票\n");
|
|
|
|
|
printf("2. 返回\n");
|
|
|
|
|
printf("请选择(1-2)\n:");
|
|
|
|
|
scanf("%d", &i);
|
|
|
|
|
if (i == 1)
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
Load();
|
|
|
|
|
printf("请输入要退票的班次:\n");
|
|
|
|
|
scanf("%s", num);
|
|
|
|
|
i = FindCarByNum(num); //调用班次查询函数
|
|
|
|
|
if (strcmp(num, records[i].number) == 0) //判断字符串比较是否相等 待比较的字符串
|
|
|
|
|
if (Judge(i)) //判断时间是否超出函数***
|
|
|
|
|
{
|
|
|
|
|
printf("确定(Y/N)?");
|
|
|
|
|
scanf("%s", num);
|
|
|
|
|
if (num[0] == 'y' || num[0] == 'Y')
|
|
|
|
|
{
|
|
|
|
|
records[i].bought--; //使已售票加1
|
|
|
|
|
printf("退票成功!\n");
|
|
|
|
|
Save();
|
|
|
|
|
_getch(); //从控制台读取一个字符,但不显示在屏幕上
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
printf("该班车已发出,无法退票!\n");
|
|
|
|
|
_getch();
|
|
|
|
|
}
|
|
|
|
|
if (i == class_num)
|
|
|
|
|
{
|
|
|
|
|
printf("输入错误!\n");
|
|
|
|
|
_getch();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void Query()
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
char s1[10] = {'\0'}, s2[10] = {'\0'};
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("1. 按班次查询\n");
|
|
|
|
|
printf("2. 按终点站查询\n");
|
|
|
|
|
printf("3. 退出\n");
|
|
|
|
|
printf("请选择(1-3):\n");
|
|
|
|
|
scanf("%d", &i);
|
|
|
|
|
Load();
|
|
|
|
|
switch (i)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
printf("请输入要查询的班次:\n"); //////s1为班次
|
|
|
|
|
scanf("%s", s1);
|
|
|
|
|
Find(s1, s2);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
printf("请输入要查询终点站:\n"); /////s2为终点站
|
|
|
|
|
scanf("%s", s2);
|
|
|
|
|
Find(s1, s2);
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
printf("输入错误!\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
printf("按任意键继续....\n");
|
|
|
|
|
_getch();
|
|
|
|
|
}
|
|
|
|
|
void Find(char s1[], char s2[])
|
|
|
|
|
{
|
|
|
|
|
int i, h = 0, m;
|
|
|
|
|
ShowTableHead();
|
|
|
|
|
if (s2[0] == '\0')
|
|
|
|
|
m = 1; //1为无条件执行
|
|
|
|
|
else
|
|
|
|
|
m = 0;
|
|
|
|
|
for (i = 0; i < class_num; i++)
|
|
|
|
|
if (strcmp(s1, records[i].number) == 0 || strcmp(s2, records[i].to) == 0)
|
|
|
|
|
//判断字符串比较是否相等,, 待比较的字符串
|
|
|
|
|
{
|
|
|
|
|
printf("\n|----------|----------|----------|----------|--------|--------|--------|\n");
|
|
|
|
|
printf("|%10s|%5s:%-4s|%10s|%10s|%8.1f|%8d|%8d|", records[i].number, records[i].hour, records[i].min,
|
|
|
|
|
records[i].from, records[i].to, records[i].hours, records[i].max, records[i].bought);
|
|
|
|
|
h += 2;
|
|
|
|
|
if (m == 1)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
ShowTableFoot();
|
|
|
|
|
if (h == 0)
|
|
|
|
|
printf("要查找的班次不存在!\n");
|
|
|
|
|
}
|
|
|
|
|
void Insert()
|
|
|
|
|
{
|
|
|
|
|
int i, j = 5;
|
|
|
|
|
Load();
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("1. 添加班次\n");
|
|
|
|
|
printf("2. 返回\n");
|
|
|
|
|
printf("请选择(1-2)\n");
|
|
|
|
|
scanf("%d", &i);
|
|
|
|
|
if (i == 1)
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("1. 请输入要增加的班次:\n");
|
|
|
|
|
scanf("%s", records[class_num].number);
|
|
|
|
|
for (i = 0; i < class_num; i++)
|
|
|
|
|
if (strcmp(records[class_num].number, records[i].number) == 0)
|
|
|
|
|
//判断车次是否重复
|
|
|
|
|
{
|
|
|
|
|
printf("输出车次已存在!\n");
|
|
|
|
|
_getch();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (i == class_num)
|
|
|
|
|
{
|
|
|
|
|
Scanf(i, j);
|
|
|
|
|
class_num++; ///使班次数加1
|
|
|
|
|
Save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void Exploer() //列出车次表函数
|
|
|
|
|
{
|
|
|
|
|
int i, j;
|
|
|
|
|
system("cls");
|
|
|
|
|
Load();
|
|
|
|
|
ShowTableHead();
|
|
|
|
|
//ShowTableBody
|
|
|
|
|
for (i = 0, j = 0; i < class_num; i++, j += 2)
|
|
|
|
|
{
|
|
|
|
|
printf("\n|----------|----------|----------|----------|--------|--------|--------|\n");
|
|
|
|
|
if (Judge(i)) //判断时间是否超出函数***
|
|
|
|
|
printf("|%10s|%5s:%-4s|%10s|%10s|%8.1f|%8d|%8d|", records[i].number, records[i].hour,
|
|
|
|
|
records[i].min, records[i].from, records[i].to, records[i].hours,
|
|
|
|
|
records[i].max, records[i].bought);
|
|
|
|
|
else
|
|
|
|
|
printf("|%10s| 已发车 |%10s|%10s|%8.1f|%8d|%8d|", records[i].number,
|
|
|
|
|
records[i].from, records[i].to, records[i].hours, records[i].max, records[i].bought);
|
|
|
|
|
}
|
|
|
|
|
ShowTableFoot();
|
|
|
|
|
printf("\n按任意键继续....\n");
|
|
|
|
|
_getch();
|
|
|
|
|
}
|
|
|
|
|
void ShowTableHead()
|
|
|
|
|
{
|
|
|
|
|
int i = 2;
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("**************************当前所有车次表*********************************\n");
|
|
|
|
|
printf("\n|----------|----------|----------|----------|--------|--------|--------|\n");
|
|
|
|
|
printf("\n| 车次 | 发的时间 | 起点站 | 终点站 |行车时间|额定载量| 已售票 |\n");
|
|
|
|
|
}
|
|
|
|
|
void ShowTableFoot()
|
|
|
|
|
{
|
|
|
|
|
printf("\n|----------|----------|----------|----------|--------|--------|--------|\n");
|
|
|
|
|
}
|