溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

C語(yǔ)言實(shí)現(xiàn)航班管理系統(tǒng)

發(fā)布時(shí)間:2020-09-19 14:40:08 來(lái)源:腳本之家 閱讀:162 作者:dandelionLYY 欄目:編程語(yǔ)言

本文實(shí)例為大家分享了C語(yǔ)言實(shí)現(xiàn)航班管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

/*.航班管理系統(tǒng)
主界面以菜單的形式展現(xiàn),用戶可以按不同的鍵執(zhí)行不同的操作,即調(diào)用不同的函數(shù);
    ......
 用不同的函數(shù)實(shí)現(xiàn),除以下模塊,還可設(shè)計(jì)其他功能模塊:
1)輸入記錄:輸入錄入航班信息,包括:航班號(hào),起降時(shí)間,起飛抵達(dá)城市,航班票價(jià),票價(jià)折扣,航班是否滿倉(cāng)等;
2)輸出記錄:輸出信息;
3)查詢記錄:可根據(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.查詢記錄\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à)折扣,航班是否滿倉(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];//航班是否滿倉(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("是否滿倉(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à) 折扣 是否滿倉(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");
 
}
 
}
//查詢記錄
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à) 折扣 是否滿倉(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("是否滿倉(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("按回車鍵返回主菜單...\n");
getchar();
}
return 0;
}

C語(yǔ)言實(shí)現(xiàn)航班管理系統(tǒng)

C語(yǔ)言實(shí)現(xiàn)航班管理系統(tǒng)

C語(yǔ)言實(shí)現(xiàn)航班管理系統(tǒng)

C語(yǔ)言實(shí)現(xiàn)航班管理系統(tǒng)

C語(yǔ)言實(shí)現(xiàn)航班管理系統(tǒng)

C語(yǔ)言實(shí)現(xiàn)航班管理系統(tǒng)

C語(yǔ)言實(shí)現(xiàn)航班管理系統(tǒng)

C語(yǔ)言實(shí)現(xiàn)航班管理系統(tǒng)

C語(yǔ)言實(shí)現(xiàn)航班管理系統(tǒng)

C語(yǔ)言實(shí)現(xiàn)航班管理系統(tǒng)

更多學(xué)習(xí)資料請(qǐng)關(guān)注專題《管理系統(tǒng)開(kāi)發(fā)》。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持億速云。

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI