printf("%8s
%14s
%14s
%14d
%12d
%17s\n",
QC[i].NO,QC[i].name,QC[i].time,QC[i].total,QC[i].sell,QC[i].leave);
}
printf("请选择要退票的场次(例如:A):\n");
scanf("%s",b);
printf("请输入要退的张数(例如:3):\n");
scanf("%d",&m);
for(i=0;i
0)
{
if(QC[i].sell-m>=0)
{
/*判断能否退票*/
QC[i].total=QC[i].total+m;
QC[i].sell=QC[i].sell-m;
printf("\n******退票成功!******\n");
t--;
/*更新座位数量*/
/*更新售票数量*/
}
}
}
}
if(t>0)
printf("\n******退票失败!******\n");
printf("
票数
\n");
场次
电影名称
放映时间
座位数量
已售
for(i=0;iint i;
float m;
for(i=0;i0) /*文件不为空*/
{
rewind(fp); /*文件位置指针移动到文件开始位置*/
for (num=0;!feof(fp) && fread(&QC[num],sizeof(struct record),1,fp);num++);
return;
}
getch();
return;
}
void writetofile()//写入文件
{
int i;
if ((fp=fopen("p.txt","wb"))==NULL)
{
printf("\n\t\t 文件打开失败");
}
for (i=0;i<4;i++)
{
if (fwrite(&QC[i],sizeof(struct record),1,fp)!=1)
{
printf("\n\t\t 写入文件错误!\n");
}
}
fclose(fp);
}
int one(void) /*与 A 场电影的时间判断*/
{
int w=1;
char b[20];
time_t t = time(NULL);
struct tm* currentTime = localtime( &t );
if(currentTime->tm_hour*60+currentTime->tm_min-18*60-30>=10)
{
w--;
printf("\n 钢铁侠 3 已停止退票\n");
}
return w;
}
int two(void) /*与 B 场电影的时间判断*/
{
int w=1;
char b[20];
time_t t = time(NULL);
struct tm* currentTime = localtime( &t );
if(currentTime->tm_hour*60+currentTime->tm_min-19*60-30>=10)
{
w--;
printf("\n 致青春已停止退票\n");
}
return w;
}
int three(void)/*与 C 场电影的时间判断*/
{
int w=1;
char b[20];
time_t t = time(NULL);
struct tm* currentTime = localtime( &t );
if(currentTime->tm_hour*60+currentTime->tm_min-20*60>=10)
{
w--;
printf("\n 姜戈已停止退票\n");
}
return w;
}
int four(void)/*与 D 场电影的时间判断*/
{
int w=1;
char b[20];
time_t t = time(NULL);
struct tm* currentTime = localtime( &t );
if(currentTime->tm_hour*60+currentTime->tm_min-20*60-20>=10)
{
w--;
printf("\n 生化危机 4 已停止退票\n");
}
return w;
}