當前位置:首頁 » 課程大全 » 數據結構課程設計飛機票c語言

數據結構課程設計飛機票c語言

發布時間: 2021-02-02 06:59:39

⑴ 數據結構課程設計——飛機訂票系統

#include <iostream.h>
#include <stdio.h>
#include <string.h>
#include <conio.h>
#define m 4 //3架飛機
#define n 5 //每架飛機5張票

struct node
{
char name[21];
char id[21];
int seat,plane,date;
node *next,*pre;
};
struct wait
{
char name[21];
char id[21];
char phone[8];
int seat,plane,date,count;
wait *next,*pre;
};
struct piao
{
int seat[n+1];
};

void makenull();
void makenull_piao();
void makenull_information();
void list_menu();
void list_piao();
void makenull_wait();
void list_information();
void plane_information(node *head);
void book();
void add_information(node *head,int x,int y);
void add_wait(int x,int y);
void search_delete(int x);
void write_to_file();
void show_wait();
bool comp(node *x,node*y);

node *head1,*head2,*head3,*q;
wait *wait_head,*wait_end;
char c;
piao a[m];

void main()
{

makenull();
do
{ list_menu();
cout<<endl<<"choose an operation: ";
cin>>c;
if (c!='6')
switch(c)
{
case '0' : show_wait();break;
case '1' : {list_piao();book();}break;
case '2' : search_delete(1);break;
case '3' : list_piao();break;
case '4' : list_information();break;
case '5' : search_delete(0);break;
default : break;
}
}while(c!='6');
cout<<"Exit System ";
}
void makenull()
{
makenull_piao();
makenull_information();
makenull_wait();
}
void list_menu()
{ cout<<endl<<"";
cout<<endl<<" 菜單";
cout<<endl<<" ************************";
cout<<endl<<" * 0 . 查看排隊情況 *";
cout<<endl<<" * 1 . 訂票 *";
cout<<endl<<" * 2 . 退票 *";
cout<<endl<<" * 3 . 查看剩餘票 *";
cout<<endl<<" * 4 . 查看飛機信息 *";
cout<<endl<<" * 5 . 查看乘客信息 *";
cout<<endl<<" * 6 . 退出 *";
cout<<endl<<" ************************";
cout<<endl<<"";
}
void makenull_piao()
{
FILE *fp;
int i;
if((fp=fopen("piao.dat","r")) == NULL )
{
fp=fopen("piao.dat","w");
for (i=1;i<=m-1;i++)
fwrite(&a[i],sizeof(piao),1,fp);
fclose(fp);
fp=fopen("piao.dat","r");
}
for(i=1;i<=m-1;i++)
fread(&a[i],sizeof(piao),1,fp);
fclose(fp);
}
void makenull_information()
{
node *r;
FILE *fp;
int i,j,sum;

sum=a[1].seat[0]+a[2].seat[0]+a[3].seat[0];
fp=fopen("information.dat","r");
head1=new node;
head2=new node;
head3=new node;
head1->pre=NULL;
head1->next=NULL;
head2->pre=NULL;
head2->next=NULL;
head3->pre=NULL;
head3->next=NULL;
q=head1;
for(i=1;i<=sum;i++)
{
j=0;
r=new node;
fread(r,sizeof(node),1,fp);
q->next=r;
r->pre=q;
r->next=NULL;
q=q->next;
fclose(fp);
if(i==a[1].seat[0]+1) {
head2->next=q;
q->pre->next=NULL;
q->pre=head2;
}
if(i==a[1].seat[0]+a[2].seat[0]+1) {
head3->next=q;
q->pre->next=NULL;
q->pre=head3;
}
}
}

void makenull_wait()
{
wait *tempw;
FILE *fp;
tempw=new wait;
int i;
if((fp=fopen("wait.txt","r")) ==NULL )
{
fp=fopen("wait.txt","w");
fclose(fp);
}
wait_end=new wait;
wait_head=new wait;
wait_end->next=NULL;
wait_end->pre=NULL;
wait_head=wait_end;
wait_head->count=0;
fp=fopen("wait.txt","r");
fread(wait_head,sizeof(wait),1,fp);
for(i=1;i<=wait_head->count;i++)
{
fread(tempw,sizeof(wait),1,fp);
wait_end->next=tempw;
tempw->pre=wait_end;
tempw->next=NULL;
wait_end=tempw;
}
}

void list_piao()
{
int i,j;
for(i=1;i<=m-1;i++)
{
if(a[i].seat[0]!=n)
{
cout<<endl<<"第 "<<i<<" 架飛機剩餘的票 :"<<endl;
for(j=1;j<=n;j++)
if (a[i].seat[j]==0) cout<<" "<<j;
cout<<endl;
}
else cout<<endl<<"The "<<i<<" plane is full !"<<endl<<endl;
}
}
void list_information()
{
int x;
do {cout<<endl<<"顯示哪架飛機的信息 ? "; cin>>x;cout<<endl;}while(x<1 || x>=m);
cout<<endl<<"第 "<<x<<" 架飛機的信息如下 "<<endl;
if(x==1) plane_information(head1);
if(x==2) plane_information(head2);
if(x==3) plane_information(head3);
}

void plane_information(node *head)
{
node *q;
char ch;
int x=0;
if(head!=NULL && head->next!=NULL)
q=head->next;
else {
q=NULL;
cout<<"飛機空,無預訂票 !"<<endl;
}
while(q!=NULL)
{
cout<<endl<<"*******************"<<endl;
q->date=q->plane;
cout<<"日期 :"<<q->date<<endl;
cout<<"座位號 : "<<q->seat<<endl;
cout<<"姓名 : "<<q->name;
cout<<endl<<"ID 號 : "<<q->id;
q=q->next;x++;
if (x % 3 ==0) ch=getch();
}
cout<<endl;
}
void book()
{
int i,j,p;
cout<<endl<<"請選擇地點:(1、2、3) ";
do {
cin>>i;
if (i<1 || i>=m) {
cout<<endl<<"**** 超出范圍!****"<<endl<<"請重新輸入:";
}
else
{cout<<endl<<"你要訂的是到"<<i<<"地的飛機"<<endl;
cout<<endl<<"第 "<<i<<" 架飛機剩餘的票 :"<<endl;
for(p=1;p<=n;p++)
if (a[i].seat[p]==0) cout<<" "<<p;
cout<<endl;
break;}
}while(1);
cout<<endl<<"請選擇座位號 : ";
do {
cin>>j;
if (j<1 || j>n) {
cout<<endl<<"**** 超出范圍!****"<<endl<<"請重新輸入:";
}
else
{
q->date=i;
cout<<endl<<"您的訂票日期 : "<<q->date<<endl;
break;
}
}while(1);

if (a[i].seat[j]==0) {
a[i].seat[j]=1;
cout<<endl;
a[i].seat[0]++;
if(i==1) add_information(head1,1,j);
if(i==2) add_information(head2,2,j);
if(i==3) add_information(head3,3,j);
}
else
{
cout<<endl<<"**** 對不起,該座位已被預訂,您被安排到訂票等候隊列 ****"<<endl;
add_wait(i,j);
}

}
void add_wait(int x,int y)
{
wait *tempw;
tempw=new wait;
tempw->next=NULL;
cout<<"請輸入個人信息"<<endl;
cout<<endl<<"*************"<<endl;
cout<<"姓名 : ";cin>>tempw->name;
cout<<"ID號 : ";cin>>tempw->id;
cout<<"電話 :";cin>>tempw->phone;
tempw->seat=y;
tempw->plane=x;
wait_end->next=tempw;
tempw->pre=wait_end;
wait_end=wait_end->next;
cout<<endl<<"**** 正在排隊等候 ****"<<endl;
wait_head->count++;
write_to_file();
}
void show_wait()
{
wait *tempw;
tempw=wait_head->next;
if (tempw==NULL) cout<<endl<<"排隊中沒有人!"<<endl;
while(tempw!=NULL)
{
cout<<tempw->name<<" - ";
tempw=tempw->next;
}
}
void add_information(node *head,int x,int y)
{
node *temp;
temp=new node;
temp->pre=NULL;
temp->next=NULL;
cout<<"請輸入個人信息"<<endl;
cout<<endl<<"*************"<<endl;
cout<<"姓名 : ";cin>>temp->name;
cout<<"ID號 : ";cin>>temp->id;
temp->seat=y;
temp->plane=x;
temp->next=head->next;
temp->pre=head;
if (head->next!=NULL) head->next->pre=temp;
head->next=temp;
write_to_file();
cout<<endl<<"**** 訂票成功 ****"<<endl;
}
void search_delete(int x)
{
node *p,*q,*r;
wait *tempw,*tempw2,*tempw3;
int step=1,t1,t2,i;
char ch;
p=new node;
tempw=new wait;
tempw2=new wait;
tempw3=new wait;
q=head1;
cout<<endl<<"請輸入個人信息"<<endl;
cout<<"*************"<<endl;
cout<<endl<<"姓名 : ";cin>>p->name;
do{
q=q->next;
if ( (q!=NULL) &&
(comp(q,p)) )
{
cout<<endl;
q->date=q->plane;
cout<<"Located!"<<endl;
cout<<"****************";
cout<<endl<<"姓名 : "<<q->name;
cout<<endl<<"ID號 : "<<q->id;
cout<<endl<<"座位號 : "<<q->seat;
cout<<endl<<"班機號 : "<<q->plane;
cout<<endl<<"日期 : "<<q->date<<endl;
if (x==1) {
cout<<"刪除該紀錄 ? [Y/N] ";
cin>>ch;
if (ch=='Y' || ch=='y') {
t1=q->plane;
t2=q->seat;
a[t1].seat[t2]=0;
a[t1].seat[0]--;
r=q;q=q->pre;
r->pre->next=r->next;
if(r->next!=NULL) r->next->pre=r->pre;
delete(r);
cout<<"**** 記錄刪除成功 ! ****";
write_to_file();
tempw=wait_head;
for(i=0;i<wait_head->count;i++)
{
tempw=tempw->next;
if(tempw==NULL) break;
if((tempw->plane==t1) && (tempw->seat==t2))
{
strcpy(tempw3->name,tempw->name);
strcpy(tempw3->phone,tempw->phone);
cout<<endl<<"等候的人中有可以訂票的了:"<<endl;
cout<<endl<<"姓名 : "<<tempw->name;
cout<<endl<<"ID號 : "<<tempw->id<<endl;
a[t1].seat[0]++;
a[t1].seat[t2]=1;
if(tempw->plane==1) add_information(head1,1,tempw->seat);
if(tempw->plane==2) add_information(head2,2,tempw->seat);
if(tempw->plane==3) add_information(head3,3,tempw->seat);
tempw2=tempw->pre;
tempw2->next=tempw->next;
if(tempw->next==NULL) wait_end=tempw2;
else tempw->next->pre=tempw2;
delete(tempw);
wait_head->count--;
write_to_file();
cout<<endl<<"等候的"<<tempw3->name<<"已經成功訂票,已經由電話"<<tempw3->phone<<"通知了"<<endl;
break;
}
}

}
}continue;
}
else
{
if (q==NULL)
{
step++;
if(step==2) q=head2;
if(step==3) q=head3;
if(step==4) {cout<<endl<<"**** 信息檢索完畢 ****";break;}
}
}
}while(1);
}
bool comp(node *x,node *y)
{
node *p,*q;
int i,j,k;
p=x;
q=y;
i=j=0;
do
{
while ( (p->name[i] != q->name[j]) && (p->name[i] != '\0') ) i++;

if (p->name[i] == '\0') {return(false);break;}
else
{
k=i;
while ( (p->name[k] == q->name[j]) && (q->name[j]!='\0') ) {k++;j++;}
if (q->name[j]=='\0') return(true);
else
{
j=0;
i++;
}
}
}while( (q->name[j]!='\0') && (p->name[i] != '\0') );
return(false);
}

void write_to_file()
{
FILE *fp;
int i,j;
int x[m];
node *p;
wait *tempw;
tempw=new wait;
tempw=wait_head;
fp=fopen("piao.dat","w");
for (i=1;i<=m-1;i++)
{
fwrite(&a[i],sizeof(piao),1,fp);
}
fclose(fp);

fp=fopen("information.dat","w");
x[0]=0;x[1]=a[1].seat[0];
for(i=0,j=1;j<=m-1;j++) {i=i+a[j].seat[0];x[j]=a[j].seat[0]+x[j-1];}
j=1;p=head1->next;
for(j=1;j<=i;j++)
{
if(j==x[1]+1) p=head2->next;
if(j==x[2]+1) p=head3->next;
if(p==NULL)break;
fwrite(p,sizeof(node),1,fp);
p=p->next;
}
fclose(fp);

fp=fopen("wait.txt","w");
for(j=0;j<=wait_head->count;j++)
{
if(tempw==NULL)break;
fwrite(tempw,sizeof(wait),1,fp);
tempw=tempw->next;
}
fclose(fp);
}

⑵ 數據結構課程設計——航空訂票系統(C語言)

1、任務:航空客運定票的業務活動包括:查詢航線、客票預定和辦理退票等。試設計一個航空客運定票系統,以使上述業務可以藉助計算機來完成。 2、功能要求: 1) 錄入:可以錄入航班情況(數據可以存儲在一個數據文件中,數據結構、具 體數據自定) 2) 查詢:可以查詢某個航線的情況(如,輸入航班號,查詢起降時間,起飛抵 達城市,航班票價,票價折扣,確定航班是否滿倉);可以輸入起飛抵達城市, 查詢飛機航班情況; 3) 訂票:(訂票情況可以存在一個數據文件中,結構自己設定)可以訂票,如果 該航班已經無票,可以提供相關可選擇航班; 4) 退票: 可退票,退票後修改相關數據文件; 5) 客戶資料:有姓名,證件號,訂票數量及航班情況,訂單要有編號; 6) 修改航班信息:當航班信息改變可以修改航班數據文件。 3、要有一個好的界面~~~~~~~~~~~~~~~~~~~~~~~~4、需求分析 系統需求(系統要求實現的功能的具體情況)5、 概要設計 系統分析(分析系統的功能和具體模塊的劃分) 系統流程(系統的流程圖) 程序詳細代碼:

⑶ c語言課程設計。飛機訂票系統設定。麻煩大神給我找下源程序,給個鏈接就行。明天就要交作業,希望能幫下

可以給你完成一份

⑷ 數據結構課程設計(用C語言編寫)

你的畢業設計吧,平時上課就不學,現在就想用30分來乞,你真當網路知道分數是錢啊?小子,別浪費你父母的血汗錢了
另外,團IDC網上有許多產品團購,便宜有口碑

⑸ 飛機訂票系統設計 c語言

(已修改,請用最新的代碼)代碼說明:

1級菜單:選擇購買的航班號,並顯示對應座位狀態。

(我只做測試,所以初始化initFlight函數中我只初始了2個航班,需要自己按照我的代碼添)

(注意:實際開發軟體,鏈表數據是從資料庫中讀取的,需要實時同步,如果要多次調用initFlight函數,記得自己寫一個釋放內存的函數,把所有鏈表「SINFO和FLINFO」節點都釋放掉,釋放函數我沒寫,需要你自己寫!!!)

2級菜單:選擇購買對應座位號,完成購買,並實時顯示購買結果。

位置編號、座位最大排數、艙室類型、折扣等參數均由常量參數空值,需要修改自行改常量。

注意:艙室類型(我默認3個類型頭等艙、公務艙、經濟艙)對應折扣參數:tDiscount二維數組。如要如要添加新的艙室類型,必須將參數常量TYPESIZE、typeName、types、tDiscount這4個同時修改,具體看代碼備注!!

座位票價=基礎票價*類型折扣*時段折扣。

因為飛機不讓吸煙,所以我沒做吸煙區(笑),如果你需要,可以作為類型自行添加!

#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
#include<malloc.h>
#include<time.h>
//-----------------------相關參數,想改變,在這里修改!!!!!!!-----------------------------
constfloattimeDiscount=1;//時段折扣,影響所有航班最終價格,默認1
constcharcID[5]="ABCD";//位置編號
constintmaxRow=20;//位置最大排號
//注意:如果修改類型數量,types和tDiscount必須同時修改!!!
#defineTYPESIZE3//類型數量
constchartypeName[TYPESIZE][10]={"頭等艙","公務艙","經濟艙"};
constinttypes[TYPESIZE][2]={{1,2},{3,4},{5,20}};//排號對應類型。1~2排頭等艙,3~4排公務艙,5~20排經濟艙
constfloattDiscount[TYPESIZE]={1.5,1.3,1};//類型折扣。頭等艙1.5倍,公務艙1.3倍,經濟艙1倍

//-------------------------------------------------------------------------------
typedefstructseatInfo//座位信息,一條鏈表對應一個航班信息,鏈表順序從第一排左邊第一個開始往後A1~D1,A2~D2。。。
{
charcloID;//位置編號A、B、C、D
introw;//位置排號
inttype;//座位所屬類型:0:頭等艙、1:公務艙、2:經濟艙,不同類型對應不同的類型折扣tDiscount
intsell;//出售狀態,0:未出售;1:已出售
structseatInfo*next;
}SINFO;
typedefstructflightInfo//航班信息
{
charfid[10];//航班號
time_ttfTime;//起飛時間
time_tldTime;//降落時間
chartoCity[20];//抵達城市
floattPrice;//基礎票價,不同位置具有不同折扣,座位票價=基礎票價*類型折扣*時段折扣
structflightInfo*next;
structseatInfo*sHead;//對應座位鏈表的頭節點
}FLINFO;
voidmeError(void*p);
SINFO*getSINFO();//獲取座位鏈表
//addFLINFO:添加航班信息鏈表的節點flinfoHead:頭節點(第一次傳NULL會自動生成),flinfoTail:尾節點,fNew:要添加的結構信息(成員指針無需賦值)
FLINFO*addFLINFO(FLINFO**ffHead,FLINFO*flinfoTail,FLINFOfNew);//返回尾節點
time_tgetTime_tfromStr(char*sTime);//將YYYY-MM-DDhh:mm:ss格式的時間字元串轉換成time_t型數值
FLINFO*initFlight();//初始化航班信息,返回航班鏈表頭節點,如果想手動輸入,請在這里添加!!!正常軟體開發,這一步應該是從資料庫讀取!
char*getTString(structtm*tm0);//通過tm獲取時間字元串
voidshowSinfo(FLINFO*flinfo);//顯示航班對應座位信息
voidprintfFlinfo(FLINFO*flinfoHead);
FLINFO*selectFlinfo(FLINFO*flinfoHead,char*fid);//選擇航班號,返回節點
voidshowSinfo(FLINFO*flinfo);//顯示航班對應座位信息
SINFO*selectSinfo(FLINFO*flinfo,char*sid);//選擇座位,返回節點
intmain()
{
FLINFO*flinfoHead=initFlight(),*ffSelect=NULL;
SINFO*sfSelect=NULL;
charfid[10]={0},sid[10]={10};
while(1)
{
ffSelect=NULL;
sfSelect=NULL;
memset(fid,0,10);
memset(sid,0,10);
printfFlinfo(flinfoHead);
printf("請輸入要購買的航班號:");
scanf("%s",fid);
ffSelect=selectFlinfo(flinfoHead,fid);
if(!ffSelect)
{
printf("未找到對應航班,按任意鍵繼續----- ");
getch();
system("cls");
continue;
}
system("cls");
printf("航班號:%s座位信息如下: ",ffSelect->fid);

showSinfo(ffSelect);
printf("請輸入要購買的座位編號(輸入0返回主菜單):");
scanf("%s",sid);
if(!strcmp(sid,"0"))
{
system("cls");
continue;
}
else
{
sfSelect=selectSinfo(ffSelect,sid);
if(!sfSelect||sfSelect->sell)
{
printf("未找到對應座位或該座位已出售,請重新輸入!按任意鍵繼續----- ");
getch();
system("cls");
continue;
}
printf("購買成功!按任意鍵繼續-----");
sfSelect->sell=1;
getch();
system("cls");
}

}
return0;
}
SINFO*selectSinfo(FLINFO*flinfo,char*sid)//選擇座位,返回節點
{
SINFO*sinfoHead=flinfo->sHead;
while(sinfoHead->next)
{
if(sinfoHead->next->cloID==sid[0]&&sinfoHead->next->row==atoi(sid+1))
returnsinfoHead->next;
sinfoHead=sinfoHead->next;
}
returnNULL;
}
voidshowSinfo(FLINFO*flinfo)//顯示航班對應座位信息
{
SINFO*sinfoHead=flinfo->sHead,*sfp=NULL;
inti,j,k,row=maxRow,clo=strlen(cID);
chartypeStr[10]={0};
for(i=0;i<row;i++)
{
//---------讀取座位所屬艙室------------
memset(typeStr,0,10);
for(k=0;k<TYPESIZE;k++)
if(i+1>=types[k][0]&&i+1<=types[k][1])
strcpy(typeStr,typeName[k]);
//--------------------------------------
printf(" ");
for(j=0;j<clo;j++)
printf("-------------");
printf(" ");
sfp=sinfoHead;

for(j=0;j<clo;j++)
{
printf("|%c%02d|",sfp->next->cloID,sfp->next->row);
sfp=sfp->next;
}
printf(" ");
sfp=sinfoHead;
for(j=0;j<clo;j++)
{
printf("|%c|",sfp->next->sell?2:1);
sfp=sfp->next;
}
printf(" ");
sfp=sinfoHead;
for(j=0;j<clo;j++)
{
printf("|%6s:%4.0f|",typeStr,flinfo->tPrice*tDiscount[sfp->next->type]*timeDiscount);
sfp=sfp->next;
}
printf(" ");
sinfoHead=sfp;
}
for(j=0;i<clo;j++)
printf("-------");
printf(" ");

}
FLINFO*selectFlinfo(FLINFO*flinfoHead,char*fid)//選擇航班號,返回節點
{
while(flinfoHead->next)
{
if(!strcmp(flinfoHead->next->fid,fid))
returnflinfoHead->next;
flinfoHead=flinfoHead->next;
}
returnNULL;
}
voidprintfFlinfo(FLINFO*flinfoHead)
{
while(flinfoHead->next)
{
printf("目的地:%s,航班號:%s ----起飛時間:%s,抵達時間:%s ",flinfoHead->next->toCity,flinfoHead->next->fid,getTString(localtime(&flinfoHead->next->tfTime)),getTString(localtime(&flinfoHead->next->ldTime)));
flinfoHead=flinfoHead->next;
}
}
char*getTString(structtm*tm0)//通過tm獲取時間字元串
{
char*str=(char*)malloc(sizeof(char)*20),num[5]={0};
meError(str);
memset(str,0,20);
sprintf(num,"%4d",tm0->tm_year+1900);
strcat(str,num);
strcat(str,"-");

memset(num,0,5);
sprintf(num,"%02d",tm0->tm_mon);
strcat(str,num);
strcat(str,"-");

memset(num,0,5);
sprintf(num,"%02d",tm0->tm_mday);
strcat(str,num);
strcat(str,"");

memset(num,0,5);
sprintf(num,"%02d",tm0->tm_hour);
strcat(str,num);
strcat(str,":");

memset(num,0,5);
sprintf(num,"%02d",tm0->tm_min);
strcat(str,num);
strcat(str,":");

memset(num,0,5);
sprintf(num,"%02d",tm0->tm_sec);
strcat(str,num);
returnstr;
}
time_tgetTime_tfromStr(char*sTime)//將YYYY-MM-DDhh:mm:ss格式的時間字元串轉換成time_t型數值
{
time_trt;
structtm*tm1=NULL;
rt=time(NULL);
tm1=localtime(&rt);
sscanf(sTime,("%4d-%2d-%2d%2d:%2d:%2d"),&tm1->tm_year,&tm1->tm_mon,&tm1->tm_mday,&tm1->tm_hour,&tm1->tm_min,&tm1->tm_sec);
tm1->tm_year-=1900;
tm1->tm_mon--;
rt=mktime(tm1);

returnrt;

}
FLINFO*initFlight()//初始化航班信息,返回航班鏈表頭節點,如果想手動輸入,請在這里添加!!!正常軟體開發,這一步應該是從資料庫讀取!
{
FLINFO*ffHead=NULL,*flinfoTail=NULL,fNew;
//--------添加一個航班信息----需要增加按照我下面調用方式寫--------------------------------
strcpy(fNew.fid,"CI502");
fNew.tfTime=getTime_tfromStr("2019-02-2003:30:30");
fNew.ldTime=getTime_tfromStr("2019-02-2005:20:30");
strcpy(fNew.toCity,"台北");
fNew.tPrice=1000;
fNew.next=NULL;
flinfoTail=addFLINFO(&ffHead,flinfoTail,fNew);
//--------------------------------------------------------------------------------------------
strcpy(fNew.fid,"9C8921");
fNew.tfTime=getTime_tfromStr("2019-02-2014:30:30");
fNew.ldTime=getTime_tfromStr("2019-02-2016:40:30");
strcpy(fNew.toCity,"香港");
fNew.tPrice=500;
fNew.next=NULL;
flinfoTail=addFLINFO(&ffHead,flinfoTail,fNew);
returnffHead;
}
FLINFO*addFLINFO(FLINFO**ffHead,FLINFO*flinfoTail,FLINFOfNew)//返回尾節點
//添加航班信息鏈表的節點flinfoHead:頭節點(第一次傳NULL會自動生成),flinfoTail:尾節點,fNew:要添加的結構信息(成員指針無需賦值)
{
FLINFO*flinfoHead=*ffHead;
if(flinfoHead==NULL)
{
*ffHead=(FLINFO*)malloc(sizeof(FLINFO));
flinfoHead=*ffHead;
meError(flinfoHead);
flinfoHead->next=NULL;
}
FLINFO*flinfoNew=(FLINFO*)malloc(sizeof(FLINFO));
meError(flinfoNew);
flinfoNew->next=NULL;
flinfoNew->fid[0]=0;
strcpy(flinfoNew->fid,fNew.fid);
flinfoNew->ldTime=fNew.ldTime;
flinfoNew->tfTime=fNew.tfTime;
flinfoNew->toCity[0]=0;
strcpy(flinfoNew->toCity,fNew.toCity);
flinfoNew->tPrice=fNew.tPrice;
flinfoNew->sHead=getSINFO();
if(flinfoHead->next==NULL)
flinfoHead->next=flinfoNew;
else
flinfoTail->next=flinfoNew;
flinfoTail=flinfoNew;
returnflinfoTail;
}
SINFO*getSINFO()//獲取座位鏈表
{
intmaxClo=strlen(cID),cnt=maxClo*maxRow,clo=0,row=1,i;
SINFO*sinfoHead=(SINFO*)malloc(sizeof(SINFO)),*sinfoTail=NULL;
meError(sinfoHead);
sinfoHead->next=NULL;
SINFO*sinfoNew=NULL;
while(cnt--)//按順序生成對應數量的座位鏈表
{
if(clo==maxClo)
clo=0,row++;
if(row==maxRow+1)
row=1;

sinfoNew=(SINFO*)malloc(sizeof(SINFO));
meError(sinfoNew);
sinfoNew->cloID=cID[clo];
sinfoNew->row=row;
for(i=0;i<TYPESIZE;i++)
if(row>=types[i][0]&&row<=types[i][1])
{
sinfoNew->type=i;
break;
}
sinfoNew->sell=0;
sinfoNew->next=NULL;
if(sinfoHead->next==NULL)
sinfoHead->next=sinfoNew;
else
sinfoTail->next=sinfoNew;
sinfoTail=sinfoNew;
clo++;
}
returnsinfoHead;
}
voidmeError(void*p)//內存申請失敗
{
if(p==NULL)
{
printf(" 異常:內存申請失敗!回車結束程序! ");
while(getch()!=' ');
exit(0);
}
}

⑹ 用C語言寫字元界面的飛機訂票系統(課程設計),想在主界面上弄一個好看的界面。怎樣弄

直接輸出puts("字元串");或者("字元串");
要多行輸出時記得加\
例如
printf(" \
\
, \
_/(( \
_.---. .' `\ \
.' ` ^ T= \
/ \ .--' \
| / )'-. \
; , <__..-( '-.) \
\ \-.__) ``--._) \
'.'-.__.-. \
'-...-'?);

右邊的\表示換行輸出是格式控制符。但是你要控制好每行輸出字元個數否則圖案每行位置很難對齊

⑺ C語言程序設計 編寫程序計算飛機票款.輸入艙位代碼和購票數量,輸出總票款

#include<stdio.h>
intmain(void)
{
intn;
floatf,c,y,i;
charg;
printf("請輸入襲F艙、C艙和Y艙的公布價; ");
scanf("%f%f%f",&f,&c,&y);
getchar();
printf("請輸入倉位代碼和購票數量; ");
scanf("%c%d",&g,&n);
switch(g)
{
case'B':i=y*0.9*n;break;
case'H':i=y*0.85*n;break;
case'K':i=y*0.8*n;break;
case'L':i=y*0.75*n;break;
case'M':i=y*0.7*n;break;
case'N':i=y*0.65*n;break;
case'Q':i=y*0.6*n;break;
case'T':i=y*0.55*n;break;
case'X':i=y*0.5*n;break;
}
printf("%.2f ",i);
}

⑻ 數據結構課程設計……關於飛機票系統 哪位高手幫我做做啊

汗,難道這個課的老師不能換點題材嗎?當年我們也是寫這個,還要答辯.....
用VB寫下很簡單的啊樓主,看你的要求還沒涉及到網路聯機...當初我們寫的時候要求最少2電腦,一台寫伺服器,一台寫客戶端,實現查詢、定退票....許可權等等....比較煩,你這個自己寫下吧!

建議最少給100分,可能有人會幫你寫,即便是這樣的功能,少說也有1000行代碼了!

⑼ 數據結構課程設計(C語言)

我這個和你要的差不多吧,,我做實驗用的..筆視收費

#include <iostream>
#include <string.h>
#include <string> //字元串操作
#include <iomanip>
using namespace std;
#define N 50 //學生數
#define M 10 //課程數
struct student
{ char name[20];
int number;
int score[8];
}stu[60];
string kechengming[M];

void changesort(struct student a[],int n,int j)
{int flag=1,i;
struct student temp;
while(flag)
{flag=0;
for(i=1;i<n-1;i+=2)
if(a[i].score[j]<a[i+1].score[j]) /*奇數項比較*/
{temp=a[i];
a[i]=a[i+1];
a[i+1]=temp;
flag=1;
}
for(i=0;i<n-1;i+=2)
if(a[i].score[j]<a[i+1].score[j]) /*偶數項比較*/
{temp=a[i];
a[i]=a[i+1];
a[i+1]=temp;
flag=1;
}
}
}

void print(struct student a[],int n,int j)
{
int i,k;
cout<<kechengming[j]<<"前5名數據如下:"<<endl;
cout<<setw(8)<<"名次"<<setw(8)<<"學號"<<setw(8)<<"姓名"<<setw(8)<<kechengming[j]<<endl;
k=1;
for(i=0;k<=5 && i<n;i++)
{if(i>0 && a[i].score[j]!=a[i-1].score[j])
k++;
cout<<setw(8)<<k;
cout<<setw(8)<<a[i].number;
cout<<setw(8)<<a[i].name;
cout<<setw(8)<<a[i].score[j];
cout<<endl;
}
}

int main()
{
int i,j,k,n,m;
struct student temp;
cout<<"請輸入學生數(最多為"<<N<<"個):";
cin>>n;
cout<<"請輸入課程數(最多為"<<M-2<<"個):";
cin>>m;
kechengming[m]="sum";kechengming[m+1]="avg";
for(i=0;i<m;i++)
{cout<<"請輸入第"<<i+1<<"個課程名:";
cin>>kechengming[i]; //輸入課程名
}
for(i=0;i<n;i++)
{cout<<"請輸入第"<<i+1<<"個同學的姓名:";
cin>>stu[i].name;
cout<<"請輸入第"<<i+1<<"個同學的學號:";
cin>>stu[i].number;
for(j=0;j<m;j++)
{cout<<"請輸入"<<kechengming[j]<<"的成績:";
cin>>stu[i].score[j];
}
}
for(i=0;i<n;i++)
{stu[i].score[m]=0;
for(j=0;j<m;j++)
stu[i].score[m]+=stu[i].score[j];
stu[i].score[m+1]=stu[i].score[m]/m;
}
changesort(stu,n,m);
cout<<"學生成績如下:"<<endl;
cout<<setw(6)<<"名次";
cout<<setw(6)<<"姓名";
cout<<setw(6)<<"學號";
for(i=0;i<m+2;i++)
cout<<setw(6)<<kechengming[i];
cout<<endl;
k=1;
for(i=0;i<n;i++)
{if(i>0 && stu[i].score[m]!=stu[i-1].score[m])
k++;
cout<<setw(6)<<k;
cout<<setw(6)<<stu[i].name;
cout<<setw(6)<<stu[i].number;
for(j=0;j<m+2;j++)
cout<<setw(6)<<stu[i].score[j];
cout<<endl;
}
j=0;
cout<<"請輸入您要對第幾個成績進行排序(1~"<<m<<"):";
cin>>i;
while(i>=0 && j==0)
{ if(i>0 && i<m+1)
{
changesort(stu,n,i-1);
print(stu,n,i-1);
cout<<"請輸入您要對第幾個成績進行排序:(1~"<<m<<",輸入0退出)";
cin>>i;
}
else if(i==0)
j=1;

else
{cout<<"輸入有誤,請重新輸入:";
cin>>i;
}
}

return 0;
}

熱點內容
武漢大學學生會輔導員寄語 發布:2021-03-16 21:44:16 瀏覽:612
七年級學生作文輔導學案 發布:2021-03-16 21:42:09 瀏覽:1
不屑弟高考成績 發布:2021-03-16 21:40:59 瀏覽:754
大學畢業證會有成績單 發布:2021-03-16 21:40:07 瀏覽:756
2017信陽學院輔導員招聘名單 發布:2021-03-16 21:40:02 瀏覽:800
查詢重慶2018中考成績查詢 發布:2021-03-16 21:39:58 瀏覽:21
結業考試成績怎麼查詢 發布:2021-03-16 21:28:40 瀏覽:679
14中醫醫師資格筆試考試成績查分 發布:2021-03-16 21:28:39 瀏覽:655
名著賞析課程標准 發布:2021-03-16 21:27:57 瀏覽:881
北京大學商業領袖高端培訓課程 發布:2021-03-16 21:27:41 瀏覽:919