第一篇:C車票管理系統(tǒng)
#include
///宏定義函數(shù)
#include
//串操作及內(nèi)存操作函數(shù) #include
/////調(diào)用系統(tǒng)函數(shù) #include
///時(shí)間庫函數(shù)
#include
///輸入輸出函數(shù) #define N 1000
//宏定義多條記錄 typedef struct TICKET
////定義新結(jié)構(gòu)體TICKET {
}CLASS;int class_num=0;
///初始班次總數(shù)為0
CLASS records[N];
// 多條記錄 int system_time();
//系統(tǒng)時(shí)間
void NewMessage();
//新紀(jì)錄*錄入函數(shù)****** void ShowTable1();
//線框調(diào)用1,,不用沒次輸
char num[10];
//車次編號 char hour[3];
//時(shí)間,小時(shí) char min[3];
//分鐘 char from[10];
//起始站 char to[10];
//終點(diǎn)站 float hours;
//車程實(shí)際時(shí)間 int max;
//最大車載容量 int now;
//已售票數(shù) void ShowTable2(int i);
//線框調(diào)用2,,不用沒次輸
void Display();
//顯示所有函數(shù) void add();
//增加記錄 void save();
//
保存函數(shù) void load();
// 按班次查詢函數(shù) void search();
//查詢函數(shù) void change();
//修改函數(shù)**
void quit();
////////// //退出函數(shù)****** void Ticketorder();
//
//*售票函數(shù)*** void Ticketdelete();
//刪除函數(shù)* int menu_select();
//菜單函數(shù)* int whether(int);
////判斷時(shí)間是否超出函數(shù)*** void find(char s1[],char s2[]);
//查詢函數(shù)★//s1為班次//s2為終點(diǎn)站 void deletemessage();
//刪除函數(shù) int findnum(char s1[]);
//班次查詢函數(shù) void get(int,int);
//修改及增加班次* char *menu[]={“*****************歡迎使用車票查詢系統(tǒng)*****************”, “n*******************MENU功能菜單***********************”, “n◤
★
1.錄入班次
◥”, “n◆
★
2.顯示所有班次
◆”, “n◆
★
3.查詢班次
◆”, “n◆
★
4.增加班次
◆”, “n◆
★
5.售票
◆”, “n◆
★
6.退票
◆”, “n◆
★
7.修改班次
◆”, “n◆
★
8.刪除班次
◆”, “n◣
★
9.退出
◢”};
/**************************主函數(shù)***************************/ void main(){
system(“cls”);
//刷屏
while(1)
//菜單函數(shù)循環(huán) {
switch(menu_select())
//菜單函數(shù)* { case 1: NewMessage();break;
////新紀(jì)錄*錄入函數(shù)****** case 2: Display();break;
// //顯示 case 3: search();break;
//查找函數(shù)** case 4: add();break;
// //增加記錄 case 5: Ticketorder();break;
////*售票函數(shù)*** case 6: Ticketdelete();break;
//刪除函數(shù)* case 7: change();break;
//修改函數(shù)** case 8: deletemessage();break;
//////選擇調(diào)用刪除函數(shù) case 9: quit();break;
//////退出函數(shù)******
} } } /***********************菜單函數(shù)**************************/ int menu_select()
/////////菜單函數(shù)* {
char s[5];
///定義要輸入的數(shù)字功能 int c,i;
system(“cls”);
//刷屏
system(“color 09”);//改變顏色
for(i=0;i<11;i++){ } i=0;printf(“%s”,menu[i]);
//輸出菜單各項(xiàng))
while(c<0||c>9)
//判斷是否是1到9的命令
{
printf(“n”);
///輸出換行
printf(“******************************************************”);
printf(“n請選擇(1-9):▁▂▃▄▆▇”);scanf(“%s”,s);
} c=atoi(s);
//atoi將字符串轉(zhuǎn)換成一個(gè)整數(shù)值
}
///輸出菜單面
return c;
////返回請求
/*******************************錄入函數(shù)************************************/ void NewMessage()
//*錄入函數(shù)****** {
int i=0,j=5,h;
//// char s[5];FILE *fp;
////定義文件型指針變量 system(“cls”);
//刷屏
if((fp=fopen(“d:車票管理系統(tǒng)0.dat”,“rb”))!=NULL)
//fopen打開文件
{
printf(“車票信息已經(jīng)存在請選擇增加功能!n”);
} if(i==0){
system(“cls”);
//刷屏
printf(“請輸入要錄入班次總數(shù):n”);printf(“任意輸入則返回菜單n”);scanf(“%s”,s);i=1;
//通過是1
scanf(“%d”,&class_num);
//指向班次指針 system(“cls”);
//刷屏
for(i=0;i { system(“cls”); //刷屏 printf(“請輸入第%d個(gè)班次信息:n”,i+1);h=-1; for(;h!=i;) ///循環(huán)輸出 { printf(“請輸入班次:n”);scanf(“%s”,records[i].num);for(h=0;h //判斷字符串比較是否相等,待比較的字符串 在!n“); } } break; ///返回 { printf(”輸入錯誤!該班次已存 } } } get(i,j); ////修改及增加班次* j=5; save(); //調(diào)用保存函數(shù) /*******************************顯示所有函數(shù)********************************/ void Display() //顯示所有函數(shù) { ur,records[i].min,printf(“n|----------|----------|----------|----------|--------|--------|--------|n”); printf(“|%10s|%5s:%-4s|%10s|%10s|%8.1f|%8d|%8d|”,records[i].num,records[i].hoif(whether(i)) //判斷時(shí)間是否超出函數(shù)*** int i,j;system(“cls”); //刷屏 load(); // 調(diào)用按班次查詢函數(shù) ShowTable1(); //線框調(diào)用1,,不用沒次輸 for(i=0,j=0;i /////按班次順序輸出 { records[i].from,records[i].to,records[i].hours,else records[i].max,records[i].now); printf(“|%10s| 已發(fā)車 |%10s|%10s|%8.1f|%8d|%8d|”,records[i].num,} /**********************************打印表頭***********************************************/ void ShowTable1() //線框調(diào)用1,,不用沒次輸 { int i=2;system(“cls”); //刷屏 printf(“**************************MESSAGE車程信息 records[i].from,records[i].to,records[i].hours,records[i].max,records[i].now);} ShowTable2(j); //線框調(diào)用2 printf(”n按任意鍵繼續(xù)....n“);getch(); /////從控制臺讀取一個(gè)字符,但不顯示在屏幕上 **********************************n”);printf(“n|----------|----------|----------|----------|--------|--------|--------|n”);|n“);} printf(”n| 班次 | 發(fā)車時(shí)間 | 起點(diǎn)站 | 終點(diǎn)站 |行車時(shí)間|額定載量| 已售票 /***************************************打印表尾************************************************/ void ShowTable2(int i) //線框調(diào)用2。不用沒次輸。{ } /**************************查找函數(shù)11**************************/ void search() ////查詢調(diào)用 { int i;char s1[10]={'