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

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

#include <stdio.h>

#include <stdlib.h>

struct cell

{

char* name

int time

int seat

int saled

} a,b,c,d

int sel=0

void title()

void saleproc()

int saleThread(struct cell* ce,int dd)

void tiupiaoproc()

int tiupiaoThread(struct cell* ce)

void count()

int init(struct cell* ce,char* name,int time,int seat)

{

ce->name=name

ce->time=time

ce->seat=seat

ce->saled=0

return 1

}

int saleThread(struct cell* ce,int dd)

{

if((ce->seat-ce->saled)>=dd)

{

ce->saled+=dd

printf("售票成功!按ESC键返回主菜单\n")

fflush(stdin)

int cc=_getche()

return 1

}

else

{

printf("售票失败---余票不足!按ESC键返回主菜单\n")

fflush(stdin)

int cc=_getche()

return 0

}

}

void saleproc()

{

int f=1

while(f)

{

system("cls")

printf("***********************************\n")

printf("*                                 *\n")

printf("*        厅 影片 时间 余票        *\n")

printf("*                                 *\n")

printf("* A %s %d:%d %3d *\n",a.name,a.time/60,a.time%60,a.seat-a.saled)

printf("*                                 *\n")

printf("* B %s %d:%d %3d *\n",b.name,b.time/60,b.time%60,b.seat-b.saled)

printf("*                                 *\n")

printf("* C %s %d:%d %3d *\n",c.name,c.time/60,c.time%60,c.seat-c.saled)

printf("*                                 *\n")

printf("* D %s %d:%d %3d *\n",d.name,d.time/60,d.time%60,d.seat-d.saled)

printf("*                                 *\n")

printf("***********************************\n")

printf("请选择放映厅(a,b,c,d)和要购的票数(按ESC键返回主菜单)(格式: a 5):\n")

fflush(stdin)

char cc

int dd

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

}

int tiupiaoThread(struct cell* ce)

{

if(ce->saled==0)

{

printf("撞尼玛鬼了 老子一张票都没卖, 哪来的退票???\n")

fflush(stdin)

int cc=_getche()

return 0

}

ce->saled--

printf("退票成功! 按任意键返回主菜单\n")

fflush(stdin)

int cc=_getche()

return 1

}

void tiupiaoproc()

{

int f=1

while(f)

{

system("cls")

printf("***********************************\n")

printf("*                                 *\n")

printf("*              退 票              *\n")

printf("*                                 *\n")

printf("*    A %-20s       *\n",a.name)

printf("*                                 *\n")

printf("*    B %-20s       *\n",b.name)

printf("*                                 *\n")

printf("*    C %-20s       *\n",c.name)

printf("*                                 *\n")

printf("*    D %-20s       *\n",d.name)

printf("*                                 *\n")

printf("***********************************\n")

printf("请输入要退的厅(a,b,c,d):\n")

char cc

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

}

void countproc()

{

int f=1

while(f)

{

system("cls")

printf("***********************************\n")

printf("*                                 *\n")

printf("* 统 计 *\n")

printf("*                                 *\n")

printf("* A厅: 余票 %3d 上座率 %5.2f%% *\n",a.seat-a.saled,(((float)a.saled/(float)a.seat)*100))

printf("*                                 *\n")

printf("* B厅: 余票 %3d 上座率 %5.2f%% *\n",b.seat-b.saled,(((float)b.saled/(float)b.seat)*100))

printf("*                                 *\n")

printf("* C厅: 余票 %3d 上座率 %5.2f%% *\n",c.seat-c.saled,(((float)c.saled/(float)c.seat)*100))

printf("*                                 *\n")

printf("* D厅: 余票 %3d 上座率 %5.2f%% *\n",d.seat-d.saled,(((float)d.saled/(float)d.seat)*100))

printf("*                                 *\n")

printf("***********************************\n")

printf("按ESC键返回主菜单!\n")

fflush(stdin)

int cc=_getche()

if(cc==27)

{

f=0

break

}

}

title()

}

void title()

{

int f=1

while(f)

{

system("cls")

printf("***********************************\n")

printf("*                                 *\n")

printf("*        欢迎光临牛B电影院        *\n")

printf("*                                 *\n")

printf("*            1. 售 票             *\n")

printf("*                                 *\n")

printf("*            2. 退 票             *\n")

printf("*                                 *\n")

printf("*            3. 统 计             *\n")

printf("*                                 *\n")

printf("*            4. 退 出             *\n")

printf("*                                 *\n")

printf("***********************************\n")

printf("请选择:(1,2,3,4) \n")

fflush(stdin)

scanf("%d",&sel)

getchar()

switch(sel)

{

case 1:

saleproc()

f=0

break

case 2:

tiupiaoproc()

f=0

break

case 3:

countproc()

f=0

break

case 4:

system("exit")

f=0

break

default:

break

}

}

}

int main(int argc, 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()

return 0

}

#include<iostream>

#include<iomanip>

#define LEN 20

#define ROW 20

using namespace std

void initseat(char s[LEN][ROW])

{

int i,j

for(i=0i<LENi++)

{

for(j=0j<ROWj++)

{

s[i][j]=' '

}

}

}

void printmenu()

{

cout<<"\t\t1.查询座位\t"<<"2.预定座位"<<endl

cout<<"\t\t3.打印电影票\t"<<"4.显示所有位置"<<endl

cout<<"\t\t0.退出"<<endl

}

void printseat(char s[LEN][ROW])

{

int i,j

cout<<"    "

for(i=0i<ROWi++)

cout<<setw(3)<<i+1

cout<<endl

for(i=0i<LENi++)

{

cout<<setw(3)<<i+1<<"."

for(j=0j<ROWj++)

cout<<setw(3)<<s[i][j]

cout<<endl

}

}

bool searchfull(char s[LEN][ROW])

{

int l,r

cout<<"您要查找的行数为:"

cin>>l

cout<<"您要查找的列数为:"

cin>>r

if(s[l-1][r-1]!=' ')

{

cout<<"您查找的座位已有人!!!"<<endl

return false

}

else

{

cout<<"您查找的座位没有人!!!"<<endl

return true

}

}

bool printticket(char s[LEN][ROW],int l,int r)

{

cout<<"电影名称:"<<"星际穿越"<<endl

cout<<"座位:"<<l<<"排"<<r<<"列"<<endl

cout<<"放映时间:"<<"2014年12月20日14:00"<<endl

return true

}

bool reservation(char s[LEN][ROW])

{

int l,r

cout<<"您要预定的行数为:"

cin>>l

cout<<"您要预定的列数为:"

cin>>r

if(!(l<=LEN&&l>=0&&r<=ROW&&r>=0))

{

cout<<"您的输入不合法!!!"<<endl<<"预定失败!!!"<<endl

return false

}

bool flag

if(s[l-1][r-1]=='#')

flag=false

else

flag=true

if(flag==false)

{

cout<<"此座位已有人!!!"<<endl

return false

}

s[l-1][r-1]='#'

printticket(s,l,r)

return true

}

int main()

{

char seat[LEN][ROW]

int flag,l,r

initseat(seat)

printseat(seat)

printmenu()

while(cin>>flag,flag!=0)

{

switch(flag)

{

case 1:searchfull(seat)break

case 2:reservation(seat)break

case 3:cout<<"请输入您要打印的行数:"cin>>l

   cout<<"请输入您要打印的行数:"cin>>r

   if(!(l<=LEN&&l>=0&&r<=ROW&&r>=0))

{

cout<<"您的输入不合法!!!"<<endl<<"预定失败!!!"<<endl

break

}

   printticket(seat,l,r)

break

case 4:printseat(seat)

default:break

}

printmenu()

}

return 0

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11371915.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-15
下一篇 2023-05-15

发表评论

登录后才能评论

评论列表(0条)

保存