首页 > 编程知识 正文

包含jsp航空订票系统源代码的词条

时间:2023-12-28 11:57:01 阅读:328130 作者:REOH

本文目录一览:

飞机订票系统c语言?

编制一个航班订票系统。应具备如下功能:该航班仅有一架100座飞机;该飞机座位分为吸烟区(30个座位)和无烟区(70个);订票系统界面是选择菜单:1.选吸烟区座位号;2.选无烟区座位号;用户输入自己的选择后,该区若有空位,则顺序地分配一个座号;否则致歉;若吸烟区已满而无烟区有空位,则征求顾客意见,是否愿意得到无烟区的空位,若愿意,则在无烟区分配一个座号,否则致歉退出;顾客不得自主挑选座位号;

#includecstdio

#includestdlib.h

#includestring.h

#includememory.h

#define LIN 31

#define LIE 71

static int smok[LIN];//吸烟区票

static int nosmoke[LIE];//无烟区票

void Initnosmoke();//初始化

void ASK();void Initsmok();

void nosmok();

void smoke();

int search(int *array,int size);

void show();

int main()

{

Initnosmoke();

Initsmok();show();return 0;}void Initnosmoke()//初始化无烟区票{int sun=0;for(int j=0;jLIE;j++){sun+=1;nosmoke[j]=sun;}}void Initsmok()//初始化吸烟区票{int k=0;for(int i=0;iLIN;i++){k+=1;smok[i]=k;}}int search(int *array,int size)/*该函数的作用是用来查看系统中某类票是否卖完,入股卖完了返回1,反之返回的是0*/{int i;for(i=0;isize;i++){if(array[i]!=0){return 0;}else{;}}return 1;}void nosmok()//购买无烟区票{for(int i=0;iLIE;i++){if(iLIE-1){if(nosmoke[i]!=0){printf("你票是:NOSMOKE_%dn",nosmoke[i]);nosmoke[i]=0;break;}else{;}}else{printf("对不起!NOSMOKE票已售完!");}}}void ASK()/*该函数用来询问客户是否需要买NOSMOKE票当SMOKE票卖完的情况下*/{char ask;printf("NOSMOKE票你要吗?(y/n)n");ask=getchar();if(ask =='y' || ask=='Y' ){nosmok();}else if(ask=='n' || ask=='N'){printf("谢谢!再见n");}else{printf("输入错误!n");}}void smoke()//购买吸烟区票{for(int j=0;jLIN;j++){if(jLIN-1){if(smok[j]!=0){printf("你票是: SMOKE_%dn",smok[j]);smok[j]=0;break;}else{;}}else{printf("对不起!SMOKE票已售完!");{fflush(stdin);int rec=search(nosmoke,LIE);if(rec==0){ASK();}else{printf("谢谢!n");}}}}}void window(){printf("tt欢迎使用航班订票系统n");printf("tt1.吸烟区座位n");printf("tt2.无烟区座位n");printf("tt3.退出系统n");printf("tt请选择(1~3)进行操作:n");}void show(){system("color 4a");char ch=' ';window();while(ch!='3'){fflush(stdin);ch=getchar();switch(ch){case '1':{smoke();break;}case '2':{nosmok();break;}case '3':{break;}default:break;}window();ch=getchar();}}

c语言程序设计 民航订票系统

//#includestdafx.h

#includeconio.h

#includestdio.h

#includestring.h

#includestdlib.h

typedef int status;

typedef struct airline

{

char flight_num[8]; /*航班号*/

char plane_num[8]; /*飞机号*/

char destination[20]; /*目的地*/

int total; /*座位总数*/

int left; /*剩余座位*/

struct airline *next; /*下一个结点*/

}airline;

typedef struct customer

{

char name[9]; /*顾客名*/

char flight_num[8]; /*航班号*/

int seat_num; /*座位号*/

struct customer *next; /*下一个结点*/

}customer;

airline *init_airline()

{ /*初始化链表*/

airline *l;

l=(airline*)malloc(sizeof(airline));

if(l==NULL)

{ exit(0);

}

l-next=NULL;

return l;

}

customer * init_customer()

{ /*初始化链表*/

customer *l;

l=(customer*)malloc(sizeof(customer));

if(l==NULL){

exit(0);

}

l-next=NULL;

return l;

}

status insert_airline(airline **p,char *flight_num,char *plane_num,char *destination,int total,int left)

{ /*airline链表插入操作*/

airline *q;

q=(airline*)malloc(sizeof(airline)); /*初始化*/

strcpy(q-flight_num , flight_num); /*拷贝信息*/

strcpy(q-plane_num , plane_num);

strcpy(q-destination , destination);

q-total =total;

q-left =left;

q-next=NULL;

(*p)-next=q;

(*p)=(*p)-next;

return 1;

}

status insert_customer(customer **p,char *name,char *flight_num,int seat)

{ /*customer信息插入操作*/

customer *q;

q=(customer*)malloc(sizeof(customer));

strcpy(q-name , name); /*顾客信息拷贝*/

strcpy(q-flight_num , flight_num);

q-seat_num =seat;

q-next=NULL;

(*p)-next=q;

(*p)=(*p)-next;

return 1;

}

airline *modefy_airline(airline *l,char *flight_num) /*修改airline中的数据*/

{ airline *p;

p=l-next ;

for(;p!=NULL;p=p-next )

{ if(strcmp(flight_num,p-flight_num )==0) /*查找*/

{ p-left ++;

return l;

}

}

printf("No this flight,can't make correction!n"); /*查找失败*/

return 0;

}

status delete_airline(airline *h,char *flight_num) /*删除航班*/

{ airline *p,*pr;

pr=h;

p=pr-next ;

while(p!=NULL)

{ if(strcmp(flight_num,p-flight_num )==0) /*信息匹配*/

{ pr-next =p-next ;

printf("Delete %s flightn",p-flight_num );

return 1;

}

pr=pr-next ;

p=pr-next ;

}

printf("No this flight,can't delete!n"); /*无该信息*/

return 0;

}

status delete_customer(customer *h,char *flight_num) /*顾客信息删除*/

{ customer *p,*pr;

pr=h;

p=pr-next ;

while(p!=NULL)

{ if(strcmp(flight_num,p-flight_num )==0) /*信息匹配*/

{ pr-next =p-next ; }

pr=pr-next ;

p=pr-next ;

}

return 1;

}

status delete_cus(customer *h,airline *l,char *name) /*顾客退票*/

{ customer *p,*pr;

char flight_num[8];

pr=h;

p=pr-next ;

while(p!=NULL)

{ if(strcmp(name,p-name )==0) /*找顾客姓名*/

{ strcpy(flight_num,p-flight_num ); /*找航班号*/

l=modefy_airline(l,flight_num); /*修改该航班信息*/

pr-next =p-next ;

printf("Customer %s return tickets successed!n",p-name );

return 1;

}

pr=pr-next ;

p=pr-next ;

}

printf("No this customer,can't return!n");

return 0;

}

status save_airline(airline *l) /*保存airline.dat*/

{ FILE *fp_airline;

char ch='#';

airline *p=l-next ;

char filename[]="c:\airline.dat"; /*寻找C盘中的航班信息文件*/

if((fp_airline=fopen(filename,"wb"))==NULL)

{ printf("can not open file to write:%sn",filename);

return 0;

}

for(;p!=NULL;p=p-next )

{ fprintf(fp_airline,"%s,%s,%s,%d,%d,%c",p-flight_num,p-plane_num,p-destination,p-total,p-left,ch);

fflush(stdin);

}

fclose(fp_airline);

return 1;

}

status save_customer(customer *l) /*保存顾客信息 customer.dat*/

{ FILE *fp_customer;

char ch='#';

customer *p=l-next ;

char filename[]="c:\customer.dat"; /*寻找C盘中的顾客信息文件*/

if((fp_customer=fopen(filename,"wb"))==NULL)

{ printf("can not open file to write:%sn",filename);

return 0;

}

for(;p!=NULL;p=p-next )

{ fprintf(fp_customer,"%s,%s,%d%c",p-name ,p-flight_num ,p-seat_num ,ch);

}

fclose(fp_customer);

return 1;

}

int changStrInt(char *ch) //把字符串转化为整型

{ int a=1,b=0,c=0,i;

for (i=strlen(ch)-1;i=0;i--)

{ if (ch[i]='9'ch[i]='0')

{ b=a*(ch[i]-'0');

a=a*10;

c=c+b;

}

else

{ printf("%c不合法,无法将此字符转化为整形!n",ch[i]);

return 0;

}

}

return c;

}

status insert_air(airline *l,char *flight_num,char *plane_num,char *destination,int total,int left)

{ /*airline链表插入操作*/

airline *q;

q=(airline*)malloc(sizeof(airline));

strcpy(q-flight_num , flight_num);

strcpy(q-plane_num , plane_num);

strcpy(q-destination , destination);

q-total =total;

q-left =left;

q-next=l-next ;

l-next=q;

return 1;

}

status insert_cus(customer *l,char *name,char *flight_num,int seat)

{ /*customer链表插入操作*/

customer *q;

q=(customer*)malloc(sizeof(customer));

strcpy(q-name , name);

strcpy(q-flight_num , flight_num);

q-seat_num =seat;

q-next=l-next ;

l-next=q;

return 1;

}

status load_airline(airline *l) /*读入文件中航班信息*/

{ FILE *fp_airline;

int flag=0,i=0;

char ch;

char flight_num[8]=""; /*航班号*/

char plane_num[8]=""; /*飞机号*/

char destination[20]=""; /*目的地*/

char total_str[5]="";

char left_str[5]="";

int total; /*座位总数*/

int left; /*剩余座位*/

char filename[]="c:\airline.dat";

if((fp_airline=fopen(filename,"r"))==NULL)

{ printf("can not open file to load:%sn",filename);

return 0;

}

while(!feof(fp_airline))

{ ch=fgetc(fp_airline);

if(ch!='#')

{ if(flag==0ch!=',')

{ flight_num[i]=ch; i++; }

else if(flag==1ch!=',')

{ plane_num[i]=ch; i++; }

else if(flag==2ch!=',')

{ destination[i]=ch; i++; }

else if(flag==3ch!=',')

{ total_str[i]=ch; i++; }

else if(flag==4ch!=',')

{ left_str[i]=ch; i++; }

else if (ch==',')

{

if(flag==0)

flight_num[i]='';

else if(flag==1)

plane_num[i]='';

else if(flag==2)

destination[i]='';

else if(flag==3)

total_str[i]='';

else

left_str[i]='';

flag++; i=0;

}

}

else

{ flag=0; i=0;

total=changStrInt(total_str);

left=changStrInt(left_str);

printf("%8s%8s%8s%9d%9dn",flight_num ,plane_num ,destination ,total ,left );

fflush(stdin);

////insert_air(l,flight_num,plane_num,destination,total,left);

}

}

fclose(fp_airline);

return 1;

}

status load_customer(customer *l) /*从文件读入顾客信息*/

{ FILE *fp_customer;

int flag=0,i=0;

char ch;

char name[9]="";

char flight_num[8]=""; /*航班号*/

char seat_num_str[5]="";

int seat_num; /*座位*/

char filename[50]="c:\customer.dat";

if((fp_customer=fopen(filename,"r"))==NULL)

{ printf("can not open file to load:%sn",filename);

return 0;

}

while(!feof(fp_customer))

{ ch=fgetc(fp_customer);

if(ch!='#')

{ if(flag==0ch!=',')

{ name[i]=ch; i++; }

else if(flag==1ch!=',')

{ flight_num[i]=ch; i++; }

else if(flag==2ch!=',')

{ seat_num_str[i]=ch; i++; }

else if (ch==',')

{ if(flag==0)

name[i]='';

else if(flag==1)

flight_num[i]='';

else seat_num_str[i]='';

flag++; i=0;

}

else

{ printf("ERRORn"); return 0; }

}

else

{ flag=0; i=0;

seat_num=changStrInt(seat_num_str);

printf("%15s %15s %10dn",name ,flight_num ,seat_num );

fflush(stdin);

////insert_cus(l,name,flight_num,seat_num);

}

}

fclose(fp_customer);

return 1;

}

status creat_airline(airline **l) /*创建airline单链表*/

{ airline *p=*l;

int i=0;

char *flight_num[3]={"bjnc01","bjsh02","shgz03"};

char *plane_num[3]={"plane1","plane2","plane3"};

char *destination[3]={"nc","sh","gz"};

int total[3]={100,100,100};

int left[3]={51,50,78};

for (i=0;i3;i++){

insert_airline(p,flight_num[i],plane_num[i],destination[i],total[i],left[i]);

}

return 1;

}

status creat_customer(customer **l) /*创建customer单链表*/

{ customer *p=*l;

int i=0;

char *name[3]={"yuyang","lucy","fanhong"};

char *flight_num[3]={"bjnc01","bjsh02","shgz03"};

int seat_num[3]={19,15,10};

for (i=0;i3;i++){

insert_customer(p,name[i],flight_num[i],seat_num[i]);

}

return 1;

}

status increase_air(airline *l,char *flight_num,char *plane_num,char *destination,int total) /*增加航线*/

{ airline *p=l-next ;

for(;p-next !=NULL;p=p-next){}

insert_airline(p,flight_num,plane_num,destination,total,total);

printf("Adding flight %s successed!n",flight_num);

return 1;

}

status book(airline *l,char *flight_num,customer *c,char *name) /*订票函数*/

{ airline *p=l;

customer *q=c-next ;

p=l-next ;

for(;q-next !=NULL;q=q-next){}

for(;p!=NULL;p=p-next )

{ if(strcmp(flight_num,p-flight_num )==0)

{ if(p-left 0)

{ printf("Congratulations!Tickets booked!n");

printf("Your seat_number is: %dn",(p-total -p-left +1));

insert_customer(q,name,flight_num,p-total -p-left +1);

p-left --;

return 1;

}

else printf("Sorry!Seats full!n");

return 0;

}

}

printf("Sorry!No this flight!n");

return 0;

}

status print_airline(airline *l) /*打印航线信息*/

{ airline *p=l-next ;

for(;p!=NULL;p=p-next )

{ printf("%8s%8s%8s%9d%9dn",p-flight_num ,p-plane_num ,p-destination ,p-total ,p-left );

}

return 1;

}

status print_customer(customer *l) /*打印顾客信息*/

{

customer *p=l-next ;

for(;p!=NULL;p=p-next )

{ printf("%10s %10s %dn",p-name ,p-flight_num ,p-seat_num );

}

return 1;

}

void main()

{ char choice,name[9],flight_num[8];

int t=1,k=1;

airline *air=init_airline();

customer *cus=init_customer();

printf("Airline Tickets Book Systemn");

printf(" n");

creat_airline(air);

creat_customer(cus);

while(t==1)

{ printf("n");

printf("**Welcome To Airline Tickets Book System**n");

printf("n");

printf("########################################n");

printf("----++++++++-------主菜单-----++++++++++-------n");

printf("# 订票-------0 #n");

printf("# 退票-------1 #n");

printf("#查询-------2 #n");

printf("#信息载入---3 #n");

printf("#退出------4 #n");

printf("###################################n");

if(k) { printf("请选择相应操作: n"); k=0; }

else printf("请选择相应操作:n");

choice = getch();

printf("%cn",choice);

if(choice=='0')

{ printf("Please input your flight number: ");

scanf( "%s",flight_num);

printf("Please input your name: ");

scanf( "%s",name);

book(air,flight_num,cus,name);

save_airline(air);

save_customer(cus);

}

else if(choice=='1')

{ printf("nPlease input your name: ");

scanf( "%s",name);

delete_cus(cus,air,name);

save_airline(air);

save_customer(cus);

}

else if(choice=='2')

{ printf("n flight_number plane_number destination total tickets_num left tickets_numn");

print_airline(air);

printf(" name flight_number seat_numbern");

print_customer(cus);

}

else if(choice=='3')

{ printf("flight_num plane_num destination total leftn" );

load_airline(air);

printf("t name ttflight_numtseat_num n");

load_customer(cus);

}

else if(choice=='4')

{ printf("Good bye!Please enjoy your travel!");

t=0;

}

else

{ printf("Input error!n");

}

}

getch();

}

代码全给你了,课设自己写,呵呵

飞机订票系统设计 c语言

(已修改,请用最新的代码)代码说明:

1级菜单:选择购买的航班号,并显示对应座位状态。

(我只做测试,所以初始化initFlight函数中我只初始了2个航班,需要自己按照我的代码添)

(注意:实际开发软件,链表数据是从数据库中读取的,需要实时同步,如果要多次调用initFlight函数,记得自己写一个释放内存的函数,把所有链表“SINFO和FLINFO”节点都释放掉,释放函数我没写,需要你自己写!!!)

2级菜单:选择购买对应座位号,完成购买,并实时显示购买结果。

位置编号、座位最大排数、舱室类型、折扣等参数均由常量参数空值,需要修改自行改常量。

注意:舱室类型(我默认3个类型头等舱、公务舱、经济舱)对应折扣参数:tDiscount二维数组。如要如要添加新的舱室类型,必须将参数常量TYPESIZE、typeName、types、tDiscount这4个同时修改,具体看代码备注!!

座位票价=基础票价*类型折扣*时段折扣。

因为飞机不让吸烟,所以我没做吸烟区(笑),如果你需要,可以作为类型自行添加!

#includestdio.h

#includestdlib.h

#includeconio.h

#includestring.h

#includemalloc.h

#includetime.h

//-----------------------相关参数,想改变,在这里修改!!!!!!!-----------------------------

const float timeDiscount=1;//时段折扣,影响所有航班最终价格,默认1

const char cID[5]="ABCD";//位置编号

const int maxRow=20;//位置最大排号

//注意:如果修改类型数量,types和tDiscount必须同时修改!!!

#define TYPESIZE 3//类型数量

const char typeName[TYPESIZE][10]={"头等舱","公务舱","经济舱"};

const int types[TYPESIZE][2]={{1,2},{3,4},{5,20}};//排号对应类型。1~2排头等舱,3~4排公务舱,5~20排经济舱

const float tDiscount[TYPESIZE]={1.5,1.3,1};//类型折扣。头等舱1.5倍,公务舱1.3倍,经济舱1倍

//-------------------------------------------------------------------------------

typedef struct seatInfo//座位信息,一条链表对应一个航班信息,链表顺序从第一排左边第一个开始往后A1~D1,A2~D2。。。

{

    char cloID;//位置编号A、B、C、D

    int row;//位置排号

    int type;//座位所属类型:0:头等舱、1:公务舱、2:经济舱,不同类型对应不同的类型折扣tDiscount

    int sell;//出售状态,0:未出售;1:已出售

    struct seatInfo *next;

}SINFO;

typedef struct flightInfo//航班信息

{

    char fid[10];//航班号

    time_t tfTime;//起飞时间

    time_t ldTime;//降落时间

    char toCity[20];//抵达城市

    float tPrice;//基础票价,不同位置具有不同折扣,座位票价=基础票价*类型折扣*时段折扣

    struct flightInfo *next;

    struct seatInfo *sHead;//对应座位链表的头节点

}FLINFO;

void meError(void *p);

SINFO *getSINFO();//获取座位链表

//addFLINFO:添加航班信息链表的节点flinfoHead:头节点(第一次传NULL会自动生成),flinfoTail:尾节点,fNew:要添加的结构信息(成员指针无需赋值)

FLINFO *addFLINFO(FLINFO **ffHead,FLINFO *flinfoTail,FLINFO fNew);//返回尾节点

time_t getTime_tfromStr(char *sTime);//将YYYY-MM-DD hh:mm:ss格式的时间字符串转换成time_t型数值

FLINFO *initFlight();//初始化航班信息,返回航班链表头节点,如果想手动输入,请在这里添加!!!正常软件开发,这一步应该是从数据库读取!

char *getTString(struct tm *tm0);//通过tm获取时间字符串

void showSinfo(FLINFO *flinfo);//显示航班对应座位信息

void printfFlinfo(FLINFO * flinfoHead);

FLINFO *selectFlinfo(FLINFO *flinfoHead,char *fid);//选择航班号,返回节点

void showSinfo(FLINFO *flinfo);//显示航班对应座位信息

SINFO *selectSinfo(FLINFO *flinfo,char *sid);//选择座位,返回节点

int main()

{

    FLINFO *flinfoHead=initFlight(),*ffSelect=NULL;

    SINFO *sfSelect=NULL;

    char fid[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("未找到对应航班,按任意键继续-----n");

            getch();

            system("cls");

            continue;

        }

        system("cls");

        printf("航班号:%s 座位信息如下:n",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("未找到对应座位或该座位已出售,请重新输入!按任意键继续-----n");

                getch();

                system("cls");

                continue;

            }

            printf("购买成功!按任意键继续-----");

            sfSelect-sell=1;

            getch();

            system("cls");

        }

    }

    return 0;

}

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))

            return sinfoHead-next;

        sinfoHead=sinfoHead-next;

    }

    return NULL;

}

void showSinfo(FLINFO *flinfo)//显示航班对应座位信息

{

    SINFO *sinfoHead=flinfo-sHead,*sfp=NULL;

    int i,j,k,row=maxRow,clo=strlen(cID);

    char typeStr[10]={0};

    for(i=0;irow;i++)

    {

        //---------读取座位所属舱室------------

        memset(typeStr,0,10);

        for(k=0;kTYPESIZE;k++)

            if(i+1=types[k][0]  i+1=types[k][1])

                strcpy(typeStr,typeName[k]);

        //--------------------------------------

        printf("n");

        for(j=0;jclo;j++)

            printf("------------- ");

        printf("n");

        sfp=sinfoHead;

        for(j=0;jclo;j++)

        {

            printf("|    %c%02d    | ",sfp-next-cloID,sfp-next-row);

            sfp=sfp-next;

        }

        printf("n");

        sfp=sinfoHead;

        for(j=0;jclo;j++)

        {

            printf("|     %c     | ",sfp-next-sell?2:1);

            sfp=sfp-next;

        }

        printf("n");

        sfp=sinfoHead;

        for(j=0;jclo;j++)

        {

            printf("|%6s:%4.0f| ",typeStr,flinfo-tPrice*tDiscount[sfp-next-type]*timeDiscount);

            sfp=sfp-next;

        }

        printf("n");

        sinfoHead=sfp;

    }

    for(j=0;iclo;j++)

            printf("------- ");

    printf("n");

}

FLINFO *selectFlinfo(FLINFO *flinfoHead,char *fid)//选择航班号,返回节点

{

    while(flinfoHead-next)

    {

        if(!strcmp(flinfoHead-next-fid,fid))

            return flinfoHead-next;

        flinfoHead=flinfoHead-next;

    }

    return NULL;

}

void printfFlinfo(FLINFO * flinfoHead)

{

    while(flinfoHead-next)

    {

        printf("目的地:%s,航班号:%sn----起飞时间:%s,抵达时间:%snn",flinfoHead-next-toCity,flinfoHead-next-fid,getTString(localtime(flinfoHead-next-tfTime)),getTString(localtime(flinfoHead-next-ldTime)));

        flinfoHead=flinfoHead-next;

    }

}

char *getTString(struct tm *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);

    return str;

}

time_t getTime_tfromStr(char *sTime)//将YYYY-MM-DD hh:mm:ss格式的时间字符串转换成time_t型数值

{

    time_t rt;

    struct tm *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);

    return rt;

}

FLINFO *initFlight()//初始化航班信息,返回航班链表头节点,如果想手动输入,请在这里添加!!!正常软件开发,这一步应该是从数据库读取!

{

    FLINFO *ffHead=NULL,*flinfoTail=NULL,fNew;

    //--------添加一个航班信息----需要增加按照我下面调用方式写--------------------------------

    strcpy(fNew.fid,"CI502");

    fNew.tfTime=getTime_tfromStr("2019-02-20 03:30:30");

    fNew.ldTime=getTime_tfromStr("2019-02-20 05: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-20 14:30:30");

    fNew.ldTime=getTime_tfromStr("2019-02-20 16:40:30");

    strcpy(fNew.toCity,"香港");

    fNew.tPrice=500;

    fNew.next=NULL;

    flinfoTail=addFLINFO(ffHead,flinfoTail,fNew);

    return ffHead;

}

FLINFO *addFLINFO(FLINFO **ffHead,FLINFO *flinfoTail,FLINFO fNew)//返回尾节点

//添加航班信息链表的节点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;

    return flinfoTail;

}

SINFO *getSINFO()//获取座位链表

{

    int maxClo=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;iTYPESIZE;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++;

    }

    return sinfoHead;

}

void meError(void *p)//内存申请失败

{

    if(p==NULL)

    {

        printf("n异常:内存申请失败!回车结束程序!n");

        while(getch()!='r');

        exit(0);

    }

}

手头又一份完整的基于JAVA的B/S航空预订系统的源代码 怎么让他运行起来啊 被人小白~ -。-

Myeclipse下,Files-Import,在General下面选择Existing Projects into Workspace,点击next,在Select root directory下打开项目文件夹的路径,Finish。就OK了。然后在Run as-Java Application.

谁有关于航空公司订票管理系统的c语言代码啊

没分啊,那我就拷一个还看得过去的给你吧:

#includestdio.h

#includestring.h

struct inf

{

char name[20];

long ID;

};

struct inf T[3232];

void main()

{

int c,d2,g,h,h2,i,j,k,n2,n3,x,y,z;

int n4,n9,n55,add1,add5,add6,add7,add9;

long ID2,d1;

int n[3][7];

int k2[4][8];

char s[15];

char s2[15],s3[15];

char a,d,f,add2,add3,add4,add8,add10;

int l[3232]={0},a3[100],a4[100],p3[100],a7[100],s22[100];

int n5[100],n6[100],t2[100],p2[100],a2[100],s33[100],t3[100];

int n7[10][10][10];

for(i=0;i=2;i++)

for(j=0;j=6;j++)

n[i][j]=100;

/************************************开头****************************************************/

loop2:

printf("n***************************************n");

printf(" 欢迎使用航空售票系统 n");

printf("***************************************n");

printf("n1.订票n2.退票n3.查票n4.查询n5.退出n");

printf("请输入您的选择(1-5):n");

do{ scanf("%c",a);}

while(a!='1'a!='2'a!='3'a!='4'a!='5');

/********************************************订票*******************************************/

if(a=='1')

{loop1:

{

printf("共有三个航班,请您输入您的选择(1-3):n");

do{scanf("%d",i);}

while(i3||i1);

printf("请输入你旅行的周日代码(1-7):n");

do{scanf("%ld",j);}

while(j7||j1);

printf("本航班当天余票为%d张!n",n[i-1][j-1]);

printf("n请输入您想订的座位号(1-100):n");

do{scanf("%d",k);}

while(k100||k1);

h=i+4*j+32*k;

while(l[h]==1)

{

do{printf("该票已经被订,请重新输入:n");

scanf("%d",k);h=i+4*j+32*k;}

while(k100||k1);}

printf("请输入您的姓名:n");

scanf("%s",T[h].name);

printf("n请输入您的身份证号码:n");

scanf("%ld",T[h].ID);

do

{

printf("n请输入您的目的地(1-5):n");

printf("1.天堂n2.地狱n3.蓬莱仙岛n4.台湾n5.美国n");

scanf("%d",c);

}

while(c5||c1);

switch(c)

{

case 1:strcpy (s,"天堂");break;

case 2:strcpy (s,"地狱");break;

case 3:strcpy (s,"蓬莱仙岛");break;

case 4:strcpy (s,"台湾");break;

case 5:strcpy (s,"美国");break;

}

printf("n您的订票信息如下:n");

printf("姓名 身份证号 航班号 飞行时间 目的地n");

printf("n%s%10ld 偏见%d号 周%d%13sn",T[h].name,T[h].ID,i,j,s);

printf("n");

printf("n 请再次检查您的信息。nn如果正确无误,请输入y.nn重新填写,请输入r.nn放弃订票,回主选单输入q。n");

do

{

scanf("%c",d);

}

while(d!='r'd!='q'd!='y');

}

if(d=='y')

{

n[i-1][j-1]--;

l[h]=1;

printf("n订票成功!!n");

goto loop2;

}

else if(d=='r')

goto loop1;

else goto loop2;

}

/********************************************退票*******************************************/

if(a=='2')

{

printf("n请填写退票详细信息.n");

printf("n请输入航班号(1-3):n");

do{scanf("%d",x);}

while(x3||x1);

printf("n请输入旅行周日(1-7):n");

do{scanf("%d",y);}

while(y7||y1);

printf("n请输入座位号:n");

do{scanf("%d",z);}

while(z100||z1);

printf("n请输入您的姓名:n");

scanf("%s",s2);

printf("n请输入您的身份证号:n");

scanf("%ld",ID2);

h2=x+4*y+32*z;

if(T[h2].ID==0)

{

printf("n该票没有被定出!n");

goto loop2;

}

else

{

if(T[h2].ID!=ID2||strcmp(s2,T[h2].name))

{

printf("信息出现矛盾!无法退票!n");goto loop2;}

else

{

printf("n请输入y确认退票!回主选单请输入q!n");

scanf("%c",f);

while(f!='y'f!='q')

{scanf("%c",f);}

if(f=='y')

{

printf("退票成功!n");

l[h2]=0;

n[x-1][y-1]++;}

else goto loop2;

}

}

goto loop2;

}

/*************************************查票系统************************************************/

if(a=='3')

{loop4:

printf("n请输入查询方式:n");

printf("n1.输入身份证号查询。n2.输入座位号码查询。n3.输入姓名查询。n4.返回。n");

do

{scanf("%d",g);}

while(g4||g1);

/******************身份证号查询**********************/

if(g==1)

{loop6:

printf("n请您输入您要查询的身份证号:n");

do{scanf("%ld",d1);}

while(d1==0);

n3=0;

i=36;

while(i=3231)

{

if(T[i].ID==d1l[i]==1)

{

n3++;a3[n3]=i;

}

i++;

}

if(n3==0){printf("n没有找到您输入的身份证号!n");

goto loop4;

}

else

{

for(i=1;i=n3;i++)

{

s33[i]=a3[i]/32;

t3[i]=(a3[i]-s33[i]*32)/4;

p3[i]=a3[i]-s33[i]*32-t3[i]*4;

}

printf("n您所查找的的信息为:n");

printf("n姓名 身份证号 航班号 座位号 飞行日n");

for(i=1;i=n3;i++)

printf("%s%10ld 偏见%d号%7d 周%dn",T[a3[i]].name,T[a3[i]].ID,p3[i],s33[i],t3[i]);

}

printf("n继续查找请输入y,返回输入q.n");

do{scanf("%c",add3);}

while(add3!='y'add3!='q');

if(add3=='y')

goto loop6;

else goto loop4;

}

/***********************名字查询***************************/

if(g==3)

{loop5:

printf("n请您输入您要查询的名字:n");

scanf("%s",s3);

n2=0;

i=37;

while(i=3231)

{

while(T[i].name==NULL) i++;

if(strcmp(T[i].name,s3)==0l[i]!=0)

{

a2[n2+1]=i;

n2++;

}

i++;

}

if(n2==0)

{

printf("n没有找到您输入的姓名!n");

goto loop4;

}

else

{

for(i=1;i=n2;i++)

{

s22[i]=a2[i]/32;

t2[i]=(a2[i]-s22[i]*32)/4;

p2[i]=a2[i]-s22[i]*32-t2[i]*4;

}

printf("n您所查找的的信息为:n");

printf("姓名 身份证号 航班号 座位号 飞行日n");

for(i=1;i=n2;i++)

printf("%s%10ld 偏见%d号%7d 周%dn",s3,T[a2[i]].ID,p2[i],s22[i],t2[i]);

}

printf("n继续查找请输入y,返回输入q.n");

do{scanf("%c",add2);}

while(add2!='y'add2!='q');

if(add2=='y')

goto loop5;

else

goto loop4;

}

/************************座位号码查询*****************************/

if(g==2)

{loop7:

printf("n请您输入您要查询的座位号:n");

do{ scanf("%d",d2);}

while(d21||d2100);

for(i=1;i=3;i++)

for(j=1;j=7;j++)

k2[i][j]=d2*32+4*j+i;

i=1;

n4=0;

while(i=3)

{

j=1;

while(j=7)

{

if(T[k2[i][j]].ID!=0l[k2[i][j]]!=0)

{

n4++;

n5[n4]=i;

n6[n4]=j;

n7[n4][n5[n4]][n6[n4]]=k2[i][j];

}

j++;

}

i++;

}

if(n4==0){printf("n该座位号码没有被定出!n");

goto loop4;

}

else

{

printf("n您所输入的座位号信息是:n");

printf("姓名 身份证号 航班号 座位号 飞行日n");

for(i=1;i=n4;i++)

printf("%s%10ld 偏见%d号%7d 周%dn",T[n7[i][n5[i]][n6[i]]].name,T[n7[i][n5[i]][n6[i]]].ID,n5[i],d2,n6[i]);

}

printf("n继续查找请输入y,返回输入q.n");

do{scanf("%c",add4);}

while(add4!='y'add4!='q');

if(add4=='q')

goto loop4;

if(add4=='y')

goto loop7;

}

else

goto loop2;

}

/*****************************************查询系统****************************************************/

if(a=='4')

{loop8:

printf("n1.查询特定航班的余票情况。n2.查询特定航班的乘客情况。n3.返回主选单。n");

printf("n请输入您的选择(1-3):n");

do

{scanf("%d",add1);}

while(add13||add11);

if(add1==3)goto loop2;

/*******************************查余票*****************************/

if(add1==1)

{loop9:

printf("n请输入您要查询的航班号(1-3):n");

do{scanf("%d",add5);}

while(add53||add51);

printf("n请输入您要查询的飞行期(1-7):n");

do{scanf("%d",add6);}

while(add67||add61);

i=37;

n55=0;

while(i=3231)

{

if((T[i].ID==0||l[i]==0)(i-add5-add6*4)%32==0)

{

n55++;

a4[n55]=i;

}

i++;

}

printf("n第%d航班飞机周%d的余票情况是:n",add5,add6);

i=0;

for(j=i+1;j=n55;j++)

{

{

for(i=j;i=j+9;i++)

printf("%5d",a4[i]/32);

}

printf("n");j=i-1;

}

printf("n继续查找请输入y,返回输入q.n");

do{scanf("%c",add8);}

while(add8!='y'add8!='q');

if(add8=='y')

goto loop9;

else

goto loop8;

}

/*******************查询已订票信息**********************/

if(add1==2)

{loop10:

printf("n请输入您要查询的航班号(1-3):n");

do{scanf("%d",add7);}

while(add73||add71);

printf("n请输入您要查询的飞行期(1-7):n");

do{scanf("%d",add9);}

while(add97||add91);

n9=0;

i=37;

while(i=3231)

{

if(T[i].ID!=0(i-add7-add9*4)%32==0l[i]!=0)

{

n9++;

a7[n9]=i;

}

i++;

}

if(n9==0)

printf("n该航班满票,没有被定出!n");

if(n9!=0)

{

printf("n第%d航班飞机周%d的订票情况是:n",add7,add9);

printf("n姓名 身份证号 航班号 座位号 飞行日n");

for(i=1;i=n9;i++)

printf("%S%10ld 偏见%d号%7d 周%dn",T[a7[i]].name,T[a7[i]].ID,add7,(a7[i]-add7-4*add9)/32,add9);

}

printf("n继续查找请输入y,返回输入q.n");

do{scanf("%c",add10);}

while(add10!='y'add10!='q');

if(add10=='y')

goto loop10;

else

goto loop8;

}

}

}

飞机订票系统的源代码

机票预定系统概要设计说明书1.引言

1.1 编写目的

在本机票预定系统项目的前一阶段,也就是需求分析阶段中,已经将系统用户对本系统的需求做了详细的阐述,这些用户需求已经在上一阶段中对航空公司、各旅行社及机场的实地调研中获得,并在需求规格说明书中得到详尽得叙述及阐明。

本阶段已在系统的需求分析的基础上,对机票预定系统做概要设计。主要解决了实现该系统需求的程序模块设计问题。包括如何把该系统划分成若干个模块、决定各个模块之间的接口、模块之间传递的信息,以及数据结构、模块结构的设计等。在以下的概要设计报告中将对在本阶段中对系统所做的所有概要设计进行详细的说明。

在下一阶段的详细设计中,程序设计员可参考此概要设计报告,在概要设计对机票预定系统所做的模块结构设计的基础上,对系统进行详细设计。在以后的软件测试以及软件维护阶段也可参考此说明书,以便于了解在概要设计过程中所完成的各模块设计结构,或在修改时找出在本阶段设计的不足或错误。 1.2 项目背景 本项目(机票预定系统)时由浙江航空公司委托,由负责开发。

机票预定系统将由两部分组成:置于个旅行社定票点的前台客户程序,以及置于航空公司的数据库服务器。本系统与其他系统的关系如下: 1.3 定义 1.3.1 专门术语

SQL SERVER: 系统服务器所使用的数据库管理系统(DBMS)。

SQL: 一种用于访问查询数据库的语言

事务流:数据进入模块后可能有多种路径进行处理。

主键:数据库表中的关键域。值互不相同。

外部主键:数据库表中与其他表主键关联的域。

ROLLBACK: 数据库的错误恢复机制。

1

1.3.2 缩写

系统:若未特别指出,统指本机票预定系统。

SQL: Structured Query Language(结构化查询语言)。

ATM: Asynchronous Transfer Mode (异步传输模式)。

1.4 参考资料 以下列出在概要设计过程中所使用到的有关资料:

1. 机票预定系统项目计划任务书 浙江航空公司 1999/3 2.机票预定系统项目开发计划 《》软件开发小组 1999/3

3.需求规格说明书 《》软件开发小组 1999/3

4.用户操作手册(初稿) 《》软件开发小组 1999/4

5.软件工程及其应用 周苏、王文等 天津科学技术出版社 1992/1

6.软件工程 张海藩 清华大学出版社 1990/11

7.Computer Network A.S.Tanenbaun Prentice Hall 1996/01

文档所采用的标准是参照《软件工程导论》沈美明著 的“计算机软件开发文档编写指南”。

2.任务概述

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。