求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

}

设置一个数组

unsigned

char

ticket[10][一列车的站点总数]={0}

1.卖票唯纳握系统每卖一张票,将相应的站点,列车赋值为1,

比如:列车指庆1的前3站卖出票,那么把ticket[1][0],ticket[1][1],ticket[1][2]设为1.

2.卖票前先检查要到的站点是否被赋值为1。按照列车对数组进行遍历即茄旦可。

System.out.println("a == b : " + (a == b.intValue()))

System.out.println("b ==c : " + (b == c))

System.out.println("e == (c + d) : " + (e.intValue() == c.intValue() + d.intValue()))

System.out.println("e.equals(c + d) : " + e.equals(Integer.valueOf(c.intValue() + d.intValue())))

System.out.println("h == (c + d) : " + (h.longValue() == c.intValue() + d.intValue()))

System.out.println("h.equals(c + d) : " + h.equals(Integer.valueOf(c.intValue() + d.intValue())))

System.out.println("f == g : " + (f == g))

System.out.println("m == n : " + (m == n))

System.out.println("p == q : " + (p == q))

System.out.println("m == d * 2 : " + (m.doubleValue() == d.intValue() * 2))

System.out.println("p == (d + e) : " + (p.floatValue() == d.intValue() + e.intValue()))


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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存