当前位置:首页 » 课程大全 » 数据结构课程设计飞机票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