1、void MainMenu():主菜单列表void ShowMenu():查询菜单列表void AddNew():添加新的数据int IsLoop():循环输入数据void Display():输出所有的函数void Search_ccity():按出站地址查询void Search_dcity():按到站地址查询void Search_ctime():按出站时刻查询void Search_dtime():按到站时刻查询void ChkData(char city1,char city2,int hour1,int minute1,int hour2,int minute2):数据检测void
2、 Record_Modify():修改数据void DeleteMenu():删除菜单列表void DeleteOne():删除一组数据void DeleteAll():删除所有数据void ReadFromFile():从文件中读入void WriteToFile():从文件中写入四、模块的算法设计(部分主要函数的代码)1.整体构造:2.结构体:struct Record int hour1; int hour2; int minute1; int minute2; char city120; char city220;;3.主菜单:void MainMenu() system(cls);
3、printf(”-主菜单-n); int option; printf(”-1添加新记录-n printf(”-2查看-n”); printf(”-3-修改-n”); printf(-4删除-n-5-退出程序-n”);请选择: n”); scanf(%d,option); getchar(); switch (option) case 1:AddNew();break; case 2:ShowMenu(); case 3:Record_Modify(); case 4:DeleteMenu(); case 5:exit(0); 4.数据检测:void ChkData(char city1,ch
4、ar city2,int hour1,int minute1,int hour2,int minute2) if (strlen(city1)20) printf(”出站地址的字符不能超过20个!n”); MainMenu(); if (strlen(city2)20) printf(到站地址不能超过20位!n MainMenu(); if (hour10|hour123)时刻输入错误(0=hour24)!n”); MainMenu(); if (hour20|hour224) printf(”时刻输入错误(0=hour MainMenu(); if (minute10|minute159)
5、printf(”时刻输入错误(0=minute59)! if (minute20|minute259)=minute59)!5.读入文件中的数据:void ReadFromFile() FILE *fp; int i; if (fp=fopen(”train。txt,rb”)=NULL) 列车时刻信息不存在,请重新建立! return; else printf(”列车信息存在,请按回车键选择操作”); if (fread(num,sizeof(int),1,fp)!=1) num=1; for(i=0;i#include stdlib.h#include ctype。hinclude mall
6、oc。conio。struct Record /*定义结构体*/ int hour1; int hour2; int minute1; int minute2; char city220;struct Record Records300; /*数组的成员个数限制了数据的数量要小于300*/int num=0;void AddNew();int IsLoop();void Display();void ShowMenu();void Search_ccity();void Search_dcity();void Search_ctime();void Search_dtime();void Ch
7、kData(char city1,char city2,int hour1,int minute1,int hour2,int minute2);void Record_Modify();void DeleteMenu();void DeleteAll();void DeleteOne();void ReadFromFile();void MainMenu();void WriteToFile();void main() /*主函数*/ ReadFromFile(); /*读取文件中的数据*/ while (1) WriteToFile();/*将数据写入文件中*/*从文件读取记录*/ FILE fp; int i; if (fp=fopen(”train.txt,”rb printf(”列车时刻信息不存在,请按回车重新建立!列车信息存在,请按回车键选择操作”); if (fread(&num,sizeof(int),1,fp)! num=1;inum; fread(Recordsi,sizeof(struct Record),1,fp);/*主菜单*/ s
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1