• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

C语言实现航班管理系统

c语言 搞代码 4年前 (2022-01-06) 36次浏览 已收录 0个评论

这篇文章主要为大家详细介绍了C语言实现航班管理系统,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了C语言实现航班管理系统的具体代码,供大家参考,具体内容如下

 /*.航班管理系统 主界面以菜单的形式展现,用户可以按不同的键执行不同的操作,即调用不同的函数; ...... 用不同的函数实现,除以下模块,还可设计其他功能模块: 1)输入记录:输入录入航班信息,包括:航班号,起降时间,起飞抵达城市,航班票价,票价折扣,航班是否满仓等; 2)输出记录:输出信息; 3)查询记录:可根据航班号查找记录; 4)删除记录:指定航班号删除该条记录; 5)插入记录:在指定位置插入新的记录。 */ #include #include #include #define N 50 int menu(); int input(struct ); void print(struct ); void search(struct flight_info info[],int n); int find_id(struct flight_info info[],int n,char *p); int del(struct,int n); int add(struct ,int n); //菜单 int menu(){ int i=1,choie; // struct flight_info *info; printf("******************航班管理系统*********************\n"); printf("\t\t%d.输入航班信息\n",i++); printf("\t\t%d.输出航班信息\n",i++); printf("\t\t%d.查询记录\n",i++); printf("\t\t%d.删除记录\n",i++); printf("\t\t%d.插入记录\n",i++); printf("\t\t%d.退出系统\n",i++); printf("****************************************************\n"); do{ printf("请输入你所选功能(1~6):"); scanf("%d",&choie); }while(choie6); return choie; } //输入航班信息 //航班号,起降时间,起飞抵达城市,航班票价,票价折扣,航班是否满仓 struct time{ int hour; int minute; }; struct flight_info{ char id[20]; //航班号 time takeoff; //起飞时间 time landing; //降落时间 char city[20]; //起降城市 float money; //航班票价 float discount;//票价折扣 char full[3];//航班是否满仓 }; int input(struct flight_info info[]){ int count; system("cls"); printf("\n请输入航班记录条数: "); scanf("%d",&count); for(int i=0;i<count;i++){ printf("\n记录号:%d\n",i+1); for(int j=0;j<20;j++){printf("-");} printf("\n航班号: ");scanf("%s",info[i].id); printf("起飞时间(x时x分)");scanf("%d%d",&info[i].takeoff.hour,&info[i].takeoff.minute); printf("降落时间(x时x分)");scanf("%d%d",&info[i].landing.hour,&info[i].landing.minute); printf("起降城市");scanf("%s",info[i].city); printf("航班票价");scanf("%f",&info[i].money); printf("票价折扣");scanf("%f",&info[i].discount); printf("是否满仓");scanf("%s",info[i].full); } return count; } //输出航班信息 void print(str<i style="color:transparent">来源gaodai$ma#com搞$$代**码)网</i>uct flight_info info[],int n){ int i; system("cls"); printf("\n******************航班信息*********************\n"); printf("航班号 起降时间 起降城市 票价 折扣 是否满仓\n"); printf("------------------------------------------------------------------\n"); for(i=0;in-1) printf("没有航班号为%s的航班!\n",s); else { system("cls"); printf("\n******************航班信息*********************\n"); printf("航班号 起降时间 起降城市 票价 折扣 是否满仓\n"); printf("------------------------------------------------------------------\n"); printf("%s\t%d:%d-%d:%d\t%s\t%.2f\t%.2f\t%s\n",info[i].id,info[i].takeoff.hour,info[i].takeoff.minute,info[i].landing.hour,info[i].landing.minute,info[i].city,info[i].money,info[i].discount,info[i].full); printf("------------------------------------------------------------------\n"); } } //删除记录 int del(struct flight_info info[],int n){ char s[20]; int ch=0; int i; printf("请输入要删除的航班号:\n"); scanf("%s",s); getchar(); i=find_id(info,n,s); if(i>n-1) printf("没有航班号为%s的航班!\n",s); else { printf("正在删除中!\n"); for(;i0){ printf("请输入插入位置的航班号,将新纪录插入在该航班号前:\n"); scanf("%s",s); //输入插入位置的姓名 getchar(); i=find_id(info,n,s); //确定插入位置 } else i=0; for(j=n-1;j>=i;j--){ strcpy(info[j+1].id,info[j].id); info[j+1].takeoff.hour=info[j].takeoff.hour; info[j+1].takeoff.minute=info[j].takeoff.minute; info[j+1].landing.hour=info[j].landing.hour; info[j+1].landing.minute=info[j].landing.minute; strcpy(info[j+1].city,info[j].city); info[j+1].money=info[j].money; info[j+1].discount=info[j].discount; strcpy(info[j+1].full,info[j].full); } strcpy(info[i].id,temp.id); info[i].takeoff.hour=temp.takeoff.hour; info[i].takeoff.minute=temp.takeoff.minute; info[i].landing.hour=temp.landing.hour; info[i].landing.minute=temp.landing.minute; strcpy(info[i].city,temp.city); info[i].money=temp.money; info[i].discount=temp.discount; strcpy(info[i].full,temp.full); n++; //记录数加1 return n;//返回记录数 } //按航班号查找函数 int find_id(flight_info info[],int n,char *p){ int i; for(i=0;i<n;i++){ if(strcmp(p,info[i].id)==0) return i; } return i; } int main(){ int length; flight_info info[N]; for(;;){ switch(menu()){ case 1:length=input(info);break; case 2:print(info,length);break; case 3:search(info,length);break; case 4:length=del(info,length);break; case 5:length=add(info,length);break; case 6:system("cls");printf("系统已关闭!!!\n感谢使用\n");exit(0);break; } printf("按回车键返回主菜单...\n"); getchar(); } return 0; }

更多学习资料请关注专题《管理系统开发》。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持gaodaima搞代码网

以上就是C语言实现航班管理系统的详细内容,更多请关注gaodaima搞代码网其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:C语言实现航班管理系统
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址