C語(yǔ)言實(shí)現(xiàn)航班管理系統(tǒng)
本文實(shí)例為大家分享了C語(yǔ)言實(shí)現(xiàn)航班管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
/*.航班管理系統(tǒng)
主界面以菜單的形式展現(xiàn),用戶(hù)可以按不同的鍵執(zhí)行不同的操作,即調(diào)用不同的函數(shù);
......
用不同的函數(shù)實(shí)現(xiàn),除以下模塊,還可設(shè)計(jì)其他功能模塊:
1)輸入記錄:輸入錄入航班信息,包括:航班號(hào),起降時(shí)間,起飛抵達(dá)城市,航班票價(jià),票價(jià)折扣,航班是否滿(mǎn)倉(cāng)等;
2)輸出記錄:輸出信息;
3)查詢(xún)記錄:可根據(jù)航班號(hào)查找記錄;
4)刪除記錄:指定航班號(hào)刪除該條記錄;
5)插入記錄:在指定位置插入新的記錄。
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#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("******************航班管理系統(tǒng)*********************\n");
printf("\t\t%d.輸入航班信息\n",i++);
printf("\t\t%d.輸出航班信息\n",i++);
printf("\t\t%d.查詢(xún)記錄\n",i++);
printf("\t\t%d.刪除記錄\n",i++);
printf("\t\t%d.插入記錄\n",i++);
printf("\t\t%d.退出系統(tǒng)\n",i++);
printf("****************************************************\n");
do{
printf("請(qǐng)輸入你所選功能(1~6):");
scanf("%d",&choie);
}while(choie<0||choie>6);
return choie;
}
//輸入航班信息
//航班號(hào),起降時(shí)間,起飛抵達(dá)城市,航班票價(jià),票價(jià)折扣,航班是否滿(mǎn)倉(cāng)
struct time{
int hour;
int minute;
};
struct flight_info{
char id[20]; //航班號(hào)
time takeoff; //起飛時(shí)間
time landing; //降落時(shí)間
char city[20]; //起降城市
float money; //航班票價(jià)
float discount;//票價(jià)折扣
char full[3];//航班是否滿(mǎn)倉(cāng)
};
int input(struct flight_info info[]){
int count;
system("cls");
printf("\n請(qǐng)輸入航班記錄條數(shù): ");
scanf("%d",&count);
for(int i=0;i<count;i++){
printf("\n記錄號(hào):%d\n",i+1);
for(int j=0;j<20;j++){printf("-");}
printf("\n航班號(hào): ");scanf("%s",info[i].id);
printf("起飛時(shí)間(x時(shí)x分)");scanf("%d%d",&info[i].takeoff.hour,&info[i].takeoff.minute);
printf("降落時(shí)間(x時(shí)x分)");scanf("%d%d",&info[i].landing.hour,&info[i].landing.minute);
printf("起降城市");scanf("%s",info[i].city);
printf("航班票價(jià)");scanf("%f",&info[i].money);
printf("票價(jià)折扣");scanf("%f",&info[i].discount);
printf("是否滿(mǎn)倉(cāng)");scanf("%s",info[i].full);
}
return count;
}
//輸出航班信息
void print(struct flight_info info[],int n){
int i;
system("cls");
printf("\n******************航班信息*********************\n");
printf("航班號(hào) 起降時(shí)間 起降城市 票價(jià) 折扣 是否滿(mǎn)倉(cāng)\n");
printf("------------------------------------------------------------------\n");
for(i=0;i<n;i++){
printf("%s\t%d:%d-%d:%d %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");
}
}
//查詢(xún)記錄
void search(struct flight_info info[],int n){
char s[20];
int i;
system("cls");
printf("請(qǐng)輸入查找航班號(hào):\n");
scanf("%s",s);
getchar();
i=find_id(info,n,s);
if(i>n-1)
printf("沒(méi)有航班號(hào)為%s的航班!\n",s);
else {
system("cls");
printf("\n******************航班信息*********************\n");
printf("航班號(hào) 起降時(shí)間 起降城市 票價(jià) 折扣 是否滿(mǎn)倉(cāng)\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("請(qǐng)輸入要?jiǎng)h除的航班號(hào):\n");
scanf("%s",s);
getchar();
i=find_id(info,n,s);
if(i>n-1)
printf("沒(méi)有航班號(hào)為%s的航班!\n",s);
else {
printf("正在刪除中!\n");
for(;i<n;i++){ //從刪除位置開(kāi)始依次前移航班記錄
strcpy(info[i].id,info[i+1].id);
info[i].takeoff.hour=info[i+1].takeoff.hour;
info[i].takeoff.minute=info[i+1].takeoff.minute;
info[i].landing.hour=info[i+1].landing.hour;
info[i].landing.minute=info[i+1].landing.minute;
strcpy(info[i].city,info[i+1].city);
info[i].money=info[i+1].money;
info[i].discount=info[i+1].discount;
strcpy(info[i].full,info[i+1].full);
}
n--; //刪除后記錄數(shù)減1
printf("刪除成功!\n");
}
return n;
}
//插入記錄
int add(struct flight_info info[],int n){
struct flight_info temp; //新插入記錄信息
int i,j;
char s[20];
printf("請(qǐng)輸入要插入的航班記錄:\n");
printf("**************************************************");
printf("\n航班號(hào): ");scanf("%s",temp.id);
printf("起飛時(shí)間(x時(shí)x分)");scanf("%d%d",&temp.takeoff.hour,&temp.takeoff.minute);
printf("降落時(shí)間(x時(shí)x分)");scanf("%d%d",&temp.landing.hour,&temp.landing.minute);
printf("起降城市");scanf("%s",temp.city);
printf("航班票價(jià)");scanf("%f",&temp.money);
printf("票價(jià)折扣");scanf("%f",&temp.discount);
printf("是否滿(mǎn)倉(cāng)");scanf("%s",temp.full);
//輸入插入信息
getchar();
printf("------------------------------------------\n");
if(n>0){
printf("請(qǐng)輸入插入位置的航班號(hào),將新紀(jì)錄插入在該航班號(hào)前:\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++; //記錄數(shù)加1
return n;//返回記錄數(shù)
}
//按航班號(hào)查找函數(shù)
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("系統(tǒng)已關(guān)閉!!!\n感謝使用\n");exit(0);break;
}
printf("按回車(chē)鍵返回主菜單...\n");
getchar();
}
return 0;
}










更多學(xué)習(xí)資料請(qǐng)關(guān)注專(zhuān)題《管理系統(tǒng)開(kāi)發(fā)》。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- C語(yǔ)言實(shí)現(xiàn)航班售票系統(tǒng) C語(yǔ)言實(shí)現(xiàn)航班管理系統(tǒng)
- C語(yǔ)言使用鏈表實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)
- C語(yǔ)言實(shí)現(xiàn)簡(jiǎn)單航班管理系統(tǒng)
- C語(yǔ)言實(shí)現(xiàn)電影院選座管理系統(tǒng)
- C語(yǔ)言通訊錄管理系統(tǒng)完整版
- C語(yǔ)言編寫(xiě)學(xué)生成績(jī)管理系統(tǒng)
- C語(yǔ)言實(shí)現(xiàn)圖書(shū)管理系統(tǒng)
- C語(yǔ)言職工信息管理系統(tǒng)源碼
- 學(xué)生信息管理系統(tǒng)C語(yǔ)言版
- 純C語(yǔ)言實(shí)現(xiàn)火車(chē)售票系統(tǒng)
相關(guān)文章
C++遍歷磁盤(pán)驅(qū)動(dòng)器的示例代碼
這篇文章主要介紹了C++遍歷磁盤(pán)驅(qū)動(dòng)器的示例代碼,幫助大家更好的理解和使用c++,感興趣的朋友可以了解下2021-01-01
C++中vector的模擬實(shí)現(xiàn)實(shí)例詳解
vector是表示可變大小數(shù)組的序列容器,它也采用連續(xù)存儲(chǔ)空間來(lái)存儲(chǔ)元素,因此可以采用下標(biāo)對(duì)vector的元素進(jìn)行訪(fǎng)問(wèn),這篇文章主要給大家介紹了關(guān)于C++中vector模擬實(shí)現(xiàn)的相關(guān)資料,需要的朋友可以參考下2021-11-11
用c語(yǔ)言實(shí)現(xiàn)冒泡排序,選擇排序,快速排序
本篇文章是對(duì)使用c語(yǔ)言實(shí)現(xiàn)冒泡排序,選擇排序,快速排序的代碼進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-05-05
QT中QColorDialog開(kāi)發(fā)實(shí)例
QColorDialog是Qt框架中用于選擇顏色的對(duì)話(huà)框類(lèi),本文主要介紹了QT中QColorDialog開(kāi)發(fā)實(shí)例,具有一定的參考價(jià)值,感興趣的可以了解一下2023-11-11
QTimer與QTime實(shí)現(xiàn)電子時(shí)鐘
這篇文章主要為大家詳細(xì)介紹了QTimer與QTime實(shí)現(xiàn)電子時(shí)鐘,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-07-07

