当前位置:首页 » 编程语言 » c语言售票系统设计
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

c语言售票系统设计

发布时间: 2022-01-25 23:28:55

⑴ 设计一个火车订票系统(c语言程序)求大神帮忙!

你这要求也太复杂了,等着吧

⑵ C语言问题---设计车票售票系统

4565463v刹徐州

⑶ C语言课程设计 简单的汽车售票系统 帮忙啊!!!!!

本来想向你多勒索点分再给你发,没想到你的积分是-6分,无语了。
使用的时候先在D盘根目录下建一个空文件file.dat,应该就可以用了。第四项和第五项你自己想法做吧。
#include<stdio.h>
int showmenu()
{
int a;
printf("**********************\n");
printf("1、订票\n");
printf("2、退票\n");
printf("3、显示订票情况\n");
printf("4、保存当天数据\n");
printf("5、退出\n");
printf("**********************\n");
printf("请选择操作\n");
scanf("%d",&a);
return a;
}
void display(int*bus)
{
printf("车次 发车时间 载客量 已售票\n");
printf("1、 06:40 50 %d\n",*bus);
printf("2、 09:30 40 %d\n",*(bus+1));
printf("3、 13:00 40 %d\n",*(bus+2));
printf("4、 16:00 40 %d\n",*(bus+3));
printf("5、 20:50 50 %d\n",*(bus+4));
}
void order(int*bus)
{
int a;
int capacity[5]={50,40,40,40,50};
display(bus);
printf("请选择要订的车次\n");
scanf("%d",&a);
if(a>5||a<1)
printf("你选择了错误的序号\n");
else if(*(bus+a-1)>=capacity[a-1])
printf("该路车的票已售罄\n");
else
{
*(bus+a-1)+=1;
printf("订票成功\n");
}
}
void cancel(int*bus)
{
int a;
display(bus);
printf("请选择要取消订票的车次\n");
scanf("%d",&a);
if(a>5||a<1)
printf("你选择了错误的序号\n");
else if(*(bus+a-1)<1)
printf("该路车尚无人订票\n");
else
{
*(bus+a-1)-=1;
printf("退票成功\n");
}
}
void writefile(int*bus)
{
FILE *fp;
if((fp=fopen("D:\\file.dat","wb"))==0)
{
printf("打不开文件\n");
exit(0);
}
fwrite(bus,sizeof(int),5,fp);
fclose(fp);
}
void readfile(int*bus)
{
int i;
FILE *fp;
if((fp=fopen("D:\\file.dat","rb"))==0)
{
printf("打不开文件\n");
exit(0);
}
for(i=0;i<5;i++)
{
if(!feof(fp))
fread(bus+i,sizeof(int),1,fp);
}
fclose(fp);
}
void main()
{
int bus[5]={0,0,0,0,0};
int a;
readfile(bus);
a=showmenu();
while(a!=5)
{
switch(a)
{
case 1:order(bus);break;
case 2:cancel(bus);break;
case 3:display(bus);break;
case 4:writefile(bus);break;
default:printf("你选择了错误的序号\n");break;
}
a=showmenu();
}
writefile(bus);
}

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

//#include<stdafx.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.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 flight\n",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:%s\n",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:%s\n",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]="\0"; /*航班号*/
char plane_num[8]="\0"; /*飞机号*/
char destination[20]="\0"; /*目的地*/
char total_str[5]="\0";
char left_str[5]="\0";
int total; /*座位总数*/
int left; /*剩余座位*/
char filename[]="c:\\airline.dat";
if((fp_airline=fopen(filename,"r"))==NULL)
{ printf("can not open file to load:%s\n",filename);
return 0;
}
while(!feof(fp_airline))
{ ch=fgetc(fp_airline);
if(ch!='#')
{ if(flag==0&&ch!=',')
{ flight_num[i]=ch; i++; }
else if(flag==1&&ch!=',')
{ plane_num[i]=ch; i++; }
else if(flag==2&&ch!=',')
{ destination[i]=ch; i++; }
else if(flag==3&&ch!=',')
{ total_str[i]=ch; i++; }
else if(flag==4&&ch!=',')
{ left_str[i]=ch; i++; }
else if (ch==',')
{
if(flag==0)
flight_num[i]='\0';
else if(flag==1)
plane_num[i]='\0';
else if(flag==2)
destination[i]='\0';
else if(flag==3)
total_str[i]='\0';
else
left_str[i]='\0';
flag++; i=0;
}
}
else
{ flag=0; i=0;
total=changStrInt(total_str);
left=changStrInt(left_str);
printf("%8s%8s%8s%9d%9d\n",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]="\0";
char flight_num[8]="\0"; /*航班号*/
char seat_num_str[5]="\0";
int seat_num; /*座位*/
char filename[50]="c:\\customer.dat";
if((fp_customer=fopen(filename,"r"))==NULL)
{ printf("can not open file to load:%s\n",filename);
return 0;
}
while(!feof(fp_customer))
{ ch=fgetc(fp_customer);
if(ch!='#')
{ if(flag==0&&ch!=',')
{ name[i]=ch; i++; }
else if(flag==1&&ch!=',')
{ flight_num[i]=ch; i++; }
else if(flag==2&&ch!=',')
{ seat_num_str[i]=ch; i++; }
else if (ch==',')
{ if(flag==0)
name[i]='\0';
else if(flag==1)
flight_num[i]='\0';
else seat_num_str[i]='\0';
flag++; i=0;
}
else
{ printf("ERROR\n"); return 0; }
}
else
{ flag=0; i=0;
seat_num=changStrInt(seat_num_str);
printf("%15s %15s %10d\n",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;i<3;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;i<3;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: %d\n",(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%9d\n",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 %d\n",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 System\n");
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("%c\n",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_num\n");
print_airline(air);
printf(" name flight_number seat_number\n");
print_customer(cus);
}
else if(choice=='3')
{ printf("flight_num plane_num destination total left\n" );
load_airline(air);
printf("\t name \t\tflight_num\tseat_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语言编程题目(车票售票系统),可加分

做这个要花制作人好几天的时间啊。我是会做,并且还可以根据需要美化界面等等,只是耗时间来做东西伤不起啊。

⑹ 飞机订票系统设计 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语言实现。

有啊,但很长
这里有个文档,你参考一下:
一个简单的火车票售票管理系统
http://wenku..com/view/1fd7a1707fd5360cba1adb72.html

⑻ 用C语言编写火车售票系统

如果谁能用C语言能把这么题目就这样顺利的编出来的话,他已经是编程高手了,这太高级了

⑼ 求c语言,电影院售票管理系统的设计与实现的代码

#include<stdio.h>
#include<stdlib.h>

structcell
{
char*name;
inttime;
intseat;
intsaled;
}a,b,c,d;

intsel=0;
voidtitle();
voidsaleproc();
intsaleThread(structcell*ce,intdd);
voidtiupiaoproc();
inttiupiaoThread(structcell*ce);
voidcount();

intinit(structcell*ce,char*name,inttime,intseat)
{
ce->name=name;
ce->time=time;
ce->seat=seat;
ce->saled=0;
return1;
}

intsaleThread(structcell*ce,intdd)
{
if((ce->seat-ce->saled)>=dd)
{
ce->saled+=dd;
printf("售票成功!按ESC键返回主菜单 ");
fflush(stdin);
intcc=_getche();
return1;
}
else
{
printf("售票失败---余票不足!按ESC键返回主菜单 ");
fflush(stdin);
intcc=_getche();
return0;
}
}

voidsaleproc()
{
intf=1;
while(f)
{
system("cls");
printf("*********************************** ");
printf("** ");
printf("*厅影片时间余票* ");
printf("** ");
printf("*A%s%d:%d%3d* ",a.name,a.time/60,a.time%60,a.seat-a.saled);
printf("** ");
printf("*B%s%d:%d%3d* ",b.name,b.time/60,b.time%60,b.seat-b.saled);
printf("** ");
printf("*C%s%d:%d%3d* ",c.name,c.time/60,c.time%60,c.seat-c.saled);
printf("** ");
printf("*D%s%d:%d%3d* ",d.name,d.time/60,d.time%60,d.seat-d.saled);
printf("** ");
printf("*********************************** ");
printf("请选择放映厅(a,b,c,d)和要购的票数(按ESC键返回主菜单)(格式:a5): ");
fflush(stdin);
charcc;
intdd;
dd=_getche();
if(dd==27)
{
f=0;
break;
}
else
{
cc=(char)dd;
}
scanf("%d",&dd);
switch(cc)
{
case'a':
saleThread(&a,dd);
f=0;
break;
case'b':
saleThread(&b,dd);
f=0;
break;
case'c':
saleThread(&c,dd);
f=0;
break;
case'd':
saleThread(&d,dd);
f=0;
break;
default:
break;
}
}
title();
}

inttiupiaoThread(structcell*ce)
{
if(ce->saled==0)
{
printf("撞尼玛鬼了老子一张票都没卖,哪来的退票??? ");
fflush(stdin);
intcc=_getche();
return0;
}
ce->saled--;
printf("退票成功!按任意键返回主菜单 ");
fflush(stdin);
intcc=_getche();
return1;
}

voidtiupiaoproc()
{
intf=1;
while(f)
{
system("cls");
printf("*********************************** ");
printf("** ");
printf("*退票* ");
printf("** ");
printf("*A%-20s* ",a.name);
printf("** ");
printf("*B%-20s* ",b.name);
printf("** ");
printf("*C%-20s* ",c.name);
printf("** ");
printf("*D%-20s* ",d.name);
printf("** ");
printf("*********************************** ");
printf("请输入要退的厅(a,b,c,d): ");
charcc;
fflush(stdin);
scanf("%c",&cc);
if(cc=='')
{
f=0;
break;
}
switch(cc)
{
case'a':
tiupiaoThread(&a);
f=0;
break;
case'b':
tiupiaoThread(&b);
f=0;
break;
case'c':
tiupiaoThread(&c);
f=0;
break;
case'd':
tiupiaoThread(&d);
f=0;
break;
default:
break;
}
}
title();
}

voidcountproc()
{
intf=1;
while(f)
{
system("cls");
printf("*********************************** ");
printf("** ");
printf("*统计* ");
printf("** ");
printf("*A厅:余票%3d上座率%5.2f%%* ",a.seat-a.saled,(((float)a.saled/(float)a.seat)*100));
printf("** ");
printf("*B厅:余票%3d上座率%5.2f%%* ",b.seat-b.saled,(((float)b.saled/(float)b.seat)*100));
printf("** ");
printf("*C厅:余票%3d上座率%5.2f%%* ",c.seat-c.saled,(((float)c.saled/(float)c.seat)*100));
printf("** ");
printf("*D厅:余票%3d上座率%5.2f%%* ",d.seat-d.saled,(((float)d.saled/(float)d.seat)*100));
printf("** ");
printf("*********************************** ");
printf("按ESC键返回主菜单! ");
fflush(stdin);
intcc=_getche();
if(cc==27)
{
f=0;
break;
}
}
title();
}

voidtitle()
{
intf=1;
while(f)
{
system("cls");
printf("*********************************** ");
printf("** ");
printf("*欢迎光临牛B电影院* ");
printf("** ");
printf("*1.售票* ");
printf("** ");
printf("*2.退票* ");
printf("** ");
printf("*3.统计* ");
printf("** ");
printf("*4.退出* ");
printf("** ");
printf("*********************************** ");
printf("请选择:(1,2,3,4) ");
fflush(stdin);
scanf("%d",&sel);
getchar();
switch(sel)
{
case1:
saleproc();
f=0;
break;
case2:
tiupiaoproc();
f=0;
break;
case3:
countproc();
f=0;
break;
case4:
system("exit");
f=0;
break;
default:
break;
}
}
}

intmain(intargc,char*argv[])
{
init(&a,"钢铁侠3",18*60+30,150);
init(&b,"致青春",19*60+30,150);
init(&c,"姜戈",20*60+30,150);
init(&d,"生化危机4",20*60+20,100);
title();
return0;
}

⑽ C语言程序设计之航空售票系统

你用什么编辑C?可以支持中文操作吗?