ZIPC语言课设-航班订票系统-源码+文件 50.47KB

qq_45997732需要积分:4(1积分=1元)

资源文件列表:

航班订票系统.zip 大约有6个文件
  1. 航班订票系统/flight/
  2. 航班订票系统/flight/flight.dat 232B
  3. 航班订票系统/flight/order.dat
  4. 航班订票系统/航班订票系统.cpp 19.89KB
  5. 航班订票系统/航班订票系统.exe 149.58KB
  6. 航班订票系统/

资源介绍:

http://t.csdnimg.cn/7xfIh 源码+文件
#include<stdio.h> #include<string.h> #include<math.h> #include<stdlib.h> #define SIZE 20 #define NUM 100 typedef struct{ char flightNum[SIZE]; char take_off_Time[SIZE]; char land_Time[SIZE]; char take_off_City[SIZE]; char land_City[SIZE]; float pre_Price; float discount; float now_Price; int tickets; }FLIGHT,*PFLIGHT; typedef struct{ char flightNum[SIZE]; char take_off_Time[SIZE]; char land_Time[SIZE]; char take_off_City[SIZE]; char land_City[SIZE]; float price; }ORDERFLIGHT,*PORDERFLIGHT; typedef struct{ char orderId[SIZE]; char name[SIZE]; char userId[SIZE]; ORDERFLIGHT order; }ORDER,*PORDER; void input_flight(){ FILE* fp; int i=0; int n; FLIGHT f[NUM]; if((fp=fopen("./flight/flight.dat","ab"))==NULL){ printf("无法打开文件!系统将返回上一级菜单!\n"); return; } printf("请输入预计要录入的航班数: "); scanf("%d",&n); printf("请按照顺序(航班号,起飞时间,降落时间,起飞城市,降落城市,原票价,折扣,剩余票数)依次输入相应信息;\n其中起飞和降落时间请按照形如\"2020-01-01/12:45\"的形式输入,若无折扣请输入1.0:\n"); while(1){ scanf("%s%s%s%s%s%f%f%d",f[i].flightNum,f[i].take_off_Time,f[i].land_Time,f[i].take_off_City,f[i].land_City,&f[i].pre_Price,&f[i].discount,&f[i].tickets); f[i].now_Price=f[i].pre_Price*f[i].discount; if((fwrite(&f[i],sizeof(FLIGHT),1,fp))!=1) printf("信息写入文件错误!\n"); i++; if(i==n){ int x; printf("已达到您预计要录入的数量,是否想要继续录入,若需要请输入要继续录入的数量,若需要退出请按0: "); scanf("%d",&x); if(x==0)break; else { printf("请输入:\n"); n+=x; } } } printf("航班信息录入完成!\n"); printf("\n"); fclose(fp); } void check_flight(){ FLIGHT f[NUM]; FILE* fp; int i=0; if((fp=fopen("./flight/flight.dat","rb"))==NULL){ printf("无法打开文件!系统将返回上一级!\n"); return; } printf("所有航班的信息如下所示:\n"); printf("航班号 起飞时间 降落时间 起飞地 目的地 原价 折扣 现价 剩余票数\n"); while(fread(&f[i],sizeof(FLIGHT),1,fp)) { printf("%-s %-s %-s %-8s %-s %8.2f %8.2f %8.2f %3d\n",f[i].flightNum,f[i].take_off_Time,f[i].land_Time,f[i].take_off_City,f[i].land_City,f[i].pre_Price,f[i].discount,f[i].now_Price,f[i].tickets); i++; } printf("\n"); fclose(fp); } void change_flight(){ FLIGHT f[NUM]; ORDER o[NUM]; FILE* fp1; FILE* fp2; FILE* op1; FILE* op2; char str[SIZE]; char str1[SIZE]; int i=0; int a=0; int x; int flag=0; if((fp1=fopen("./flight/flight.dat","rb"))==NULL){ printf("无法打开文件!系统将返回上一级!\n"); return; } while(fread(&f[i],sizeof(FLIGHT),1,fp1)) { i++; } if((op1=fopen("./flight/order.dat","rb"))==NULL){ printf("无法打开文件!系统将返回上一级!\n"); return; } while(fread(&o[a],sizeof(ORDER),1,op1)) { a++; } fclose(fp1); fclose(op1); printf("请输入需要修改航班的航班号: "); scanf("%s",str); for(int j=0;j<i;j++){ if(strcmp(str,f[j].flightNum)==0){ printf("已找到该航班:\n"); printf("航班号 起飞时间 降落时间 起飞地 目的地 原价 折扣 现价 剩余票数\n"); printf("%-s %-s %-s %-8s %-s %8.2f %8.2f %8.2f %3d\n",f[j].flightNum,f[j].take_off_Time,f[j].land_Time,f[j].take_off_City,f[j].land_City,f[j].pre_Price,f[j].discount,f[j].now_Price,f[j].tickets); printf("请重新输入该航班的信息;\n请按照(起飞时间,降落时间,起飞城市,降落城市,原票价,折扣,剩余票数)顺序依次输入相应信息;\n其中起飞和降落时间请按照形如\"2020-01-01/12:45\"的形式输入,若无折扣请输入1.0:\n"); scanf("%s%s%s%s%f%f%d",f[j].take_off_Time,f[j].land_Time,f[j].take_off_City,f[j].land_City,&f[j].pre_Price,&f[j].discount,&f[j].tickets); f[j].now_Price=f[j].pre_Price*f[j].discount; x=j; flag=1; } } if(flag==0)printf("您所要修改的航班并不存在!\n"); if((fp2=fopen("./flight/flight.dat","wb"))==NULL){ printf("无法打开文件!系统将返回上一级!\n"); return; } for(int j=0;j<i;j++){ if((fwrite(&f[j],sizeof(FLIGHT),1,fp2))!=1) printf("信息写入文件错误!\n"); } fclose(fp2); for(int b=0;b<a;b++){ if(strcmp(str,o[b].order.flightNum)==0){ strcpy(o[b].order.take_off_Time,f[x].take_off_Time); strcpy(o[b].order.land_Time,f[x].take_off_Time); strcpy(o[b].order.take_off_City,f[x].take_off_City); strcpy(o[b].order.land_City,f[x].land_City); strcpy(str1,f[x].flightNum); strcpy(o[b].orderId,strcat(str1,o[b].userId)); o[b].order.price=f[x].now_Price; } } if((op2=fopen("./flight/order.dat","wb"))==NULL){ printf("无法打开文件!系统将返回上一级!\n"); return; } for(int j=0;j<a;j++){ if((fwrite(&o[j],sizeof(ORDER),1,op2))!=1) printf("信息写入文件错误!\n"); } fclose(op2); printf("\n"); } void delete_flight(){ FLIGHT f[NUM]; ORDER o[NUM]; FILE* fp1; FILE* fp2; FILE* op1; FILE* op2; char str[SIZE]; int i=0; int j=0; int a=0; int b=0; int x; int flag=0; int c=0; if((fp1=fopen("./flight/flight.dat","rb"))==NULL){ printf("无法打开文件!系统将返回上一级!\n"); return; } while(fread(&f[i],sizeof(FLIGHT),1,fp1)) { i++; } if((op1=fopen("./flight/order.dat","rb"))==NULL){ printf("无法打开文件!系统将返回上一级!\n"); return; } while(fread(&o[a],sizeof(ORDER),1,op1)) { a++; } fclose(fp1); fclose(op1); printf("请输入需要删除航班的航班号:"); scanf("%s",str); for(j=0;j<i;j++){ if(strcmp(str,f[j].flightNum)==0){ printf("已找到该航班:\n"); printf("航班号 起飞时间 降落时间 起飞地 目的地 原价 折扣 现价 剩余票数\n"); printf("%-s %-s %-s %-8s %-s %8.2f %8.2f %8.2f %3d\n",f[j].flightNum,f[j].take_off_Time,f[j].land_Time,f[j].take_off_City,f[j].land_City,f[j].pre_Price,f[j].discount,f[j].now_Price,f[j].tickets); printf("确认要删除吗?(1 删除/0 取消):"); scanf("%d",&c); printf("\n"); flag=1; x=j; } } if(flag==0)printf("您所要删除的航班并不存在!\n\n"); if(c==1){ if((fp2=fopen("./flight/flight.dat","wb"))==NULL){ printf("无法打开文件!系统将返回上一级!\n"); return; } for(int k=0;k<x;k++){ if((fwrite(&f[k],sizeof(FLIGHT),1,fp2))!=1) printf("信息写入文件错误!\n"); } for(int k=x+1;k<i;k++){ if((fwrite(&f[k],sizeof(FLIGHT),1,fp2))!=1) printf("信息写入文件错误!\n"); } printf("\n"); fclose(fp2); } for(b=0;b<a;b++){ if(strcmp(str,o[b].order.flightNum)==0){ if(c==1){ if((op2=fopen("./flight/order.dat","wb"))==NULL){ printf("无法打开文件!系统将返回上一级!\n"); return; } for(int k=0;x<b;k++){ if((fwrite(&o[k],sizeof(ORDER),1,op2))!=1) printf("信息写入文件错误!\n"); } for(int k=b+1;k<a;k++){ if((fwrite(&o[k],sizeof(ORDER),1,op2))!=1) printf("信息写入文件错误!\n"); } fclose(op2); } } } } void searchByFligtNum(){ FLIGHT f[NUM]; char str[SIZE]; FILE* fp; int i=0; int flag=0; printf("请输入您想要查询的航班号: "); scanf("%s",str); if((fp=fopen("./flight/flight.dat","rb"))==NULL){ printf("无法打开文件!系统将返回上一级!\n"); return; } while(fread(&f[i],sizeof(FLIGHT),1,fp)){ i++; } for(int j=0;j<i;j++){ if(strcmp(str,f[j].flightNum)==0){ printf("查询到相关信息,如下所示:\n"); printf("航班号 起飞时间 降落时间 起飞地 目的地 原价 折扣 现价 剩余票数\n"); printf("%-s %-s %-s %-8s %-s %8.2f %8.2f %8.2f %3d\n",f[j].flightNum,f[j].take_off_Time,f[j].land_Time,f[j].take_off_City,f[j].land_City,f[j].pre_Price,f[j].discount,f[j].now_Price,f[j].tickets); flag=1; } } if(flag==0)printf("您所要查询的航班并不存在!\n"); printf("\n"); fclose(fp); } void searchByAddr(){ FLIGHT f[NUM]; char str1[SIZE]; char str2[SIZE]; FILE* fp; int i=0; int flag=0; printf("请输入您想要
100+评论
captcha
    类型标题大小时间
    ZIPMAX30102脉搏血氧仪和心率传感器库(Arduino)4.06KB2月前
    ZIPactiviti插件11.19MB2月前
    ZIPandroid4.0launcher2调试用3个classes.jar10.91MB2月前
    ZIPnginx(ngua).zip1.23MB2月前
    ZIPNAR-RNN时间序列预测代码(数据集+训练+预测+预测效果对比)274.92KB2月前
    ZIPeclipse中findbugs插件3.02MB2月前
    ZIPSQL Debug(不错的SQL语句调试工具)1.51MB2月前
    ZIPVBExplorer VB6程序反编译工具,可以了解一个VB6程序的基本的框架结构405.68KB2月前