📄 xinxi.c
字号:
case 1: //按航班号查询
system("cls");
if (em1[k].state == 0)
{
printf("\n\t\t\t\t\t\t\t\t\t管理员");
}
else
{
printf("\n\t\t\t\t\t\t\t\t\t员工");
}
printf("\n________________________________________________________________________________");
printf("\n\t\t请输入您要查询的航班号:");
fflush(stdin);
gets(p.num);
for (j = 0;j < N;j++)
{
if (strcmp(p.num, air[j].num) == 0)
{
printf("\n\n\t\t航班号为 %s 的信息如下:", p.num);
printf("\n\n\t\t起始站:%s", air[j].start);
printf("\n\n\t\t终点站:%s", air[j].finish);
printf("\n\n\t\t起飞日期:%d年%d月%d日", air[j].day.year, air[j].day.month, air[j].day.day);
printf("\n\n\t\t起飞时间:%d点%d分", air[j].hour.hour, air[j].hour.minute);
printf("\n\n\t\t剩余票数:%d", air[j].count);
printf("\n\n\t\t票价:%d", air[j].money);
printf("\n\n================================================================================");
goto loop2;
}
}
printf("\n\n\n\n\n\n\n\t\t\t没有找到您要查询的航班!!");
printf("\n\n\n\n\n\n\n\n\n================================================================================");
loop2: printf("\n\t\t\t\t(按任意键返回)");
fflush(stdin);
n=getch();
system("cls");
goto loop1;
break;
case 2: //按目的地查询
system("cls");
if (em1[k].state == 0)
{
printf("\n\t\t\t\t\t\t\t\t\t管理员");
}
else
{
printf("\n\t\t\t\t\t\t\t\t\t员工");
}
printf("\n________________________________________________________________________________");
printf("\n\t\t请输入您要查询的目的地:");
fflush(stdin);
gets(p.finish);
i = 0;
// printf("\n\n\t\t目的地为 %s 的航班信息如下:", p.finish);
// printf("\n\n\t航班号\t起始站\t起飞日期\t时间\t剩余票数\t票价");
for (j = 0;j < N;j++)
{
if (strcmp(p.finish, air[j].finish) == 0)
{
printf("\n\n\t\t目的地为 %s 的第 %d 条航班信息如下:", p.finish, i + 1);
i++;
// printf("\n\n\t%s\t%s\t%d年%d月%d日\t%d点%d分\t%d\t%d\t",air[j].num,air[j].start,air[j].day.year,air[j].day.month,air[j].day.day,air[j].hour.hour,air[j].hour.minute,air[j].count,air[j].money);
printf("\n\n\t\t航班号:%s", air[j].num);
printf("\n\n\t\t起始站:%s", air[j].start);
printf("\n\n\t\t起飞日期:%d年%d月%d日", air[j].day.year, air[j].day.month, air[j].day.day);
printf("\n\n\t\t起飞时间:%d点%d分", air[j].hour.hour, air[j].hour.minute);
printf("\n\n\t\t剩余票数:%d", air[j].count);
printf("\n\n\t\t票价:%d", air[j].money);
if (i == 1)
{
printf("\n\n================================================================================");
}
else
{
printf("\n\n\n\n================================================================================");
}
loop3: printf("\n\t\t (按1+回车显示下一条,按0+回车返回)");
fflush(stdin);
scanf("%d", &n);
switch (n)
{
case 1:
system("cls");
if (em1[k].state == 0)
{
printf("\n\t\t\t\t\t\t\t\t\t管理员");
}
else
{
printf("\n\t\t\t\t\t\t\t\t\t员工");
}
printf("\n________________________________________________________________________________");
break;
case 0:
system("cls");
goto loop1;
break;
default:
system("cls");
if (em1[k].state == 0)
{
printf("\n\t\t\t\t\t\t\t\t\t管理员");
}
else
{
printf("\n\t\t\t\t\t\t\t\t\t员工");
}
printf("\n________________________________________________________________________________");
printf("\n\n\n\n\n\n\n\t\t\t\t您的输入有误!");
printf("\n\n\n\n\n\n\n\n\n\n\n================================================================================");
goto loop3;
}
}
}
if (i == 0)
{
printf("\n\n\n\n\n\n\n\t\t\t没有找到您要查询的航班!!\n\n\n\n\n");
}
else
{
printf("\n\n\n\n\n\n\n\n\t\t\t查询已到末尾,没有下一条信息!!\n\n\n\n\n\n");
}
printf("\n\n\n\n================================================================================");
printf("\n\t\t\t\t(按任意键返回)");
fflush(stdin);
n=getch();
system("cls");
goto loop1;
break;
case 3: //按日期查询
p.day.year = -1;
p.day.month = -1;
p.day.day = -1;
system("cls");
if (em1[k].state == 0)
{
printf("\n\t\t\t\t\t\t\t\t\t管理员");
}
else
{
printf("\n\t\t\t\t\t\t\t\t\t员工");
}
printf("\n________________________________________________________________________________");
printf("\n\n\t\t请输入您要查询的日期(年-月-日):");
fflush(stdin);
scanf("%d-%d-%d", &p.day.year, &p.day.month, &p.day.day);
i = 0;
for (j = 0;j < N;j++)
{
if ((p.day.year == air[j].day.year) && (p.day.month == air[j].day.month) && (p.day.day == air[j].day.day))
{
printf("\n\n\t\t时间为 %d 年 %d 月 %d 日的航班信息如下:", p.day.year, p.day.month, p.day.day);
i++;
printf("\n\n\t\t航班号:%s", air[j].num);
printf("\n\n\t\t起始站:%s", air[j].start);
printf("\n\n\t\t起飞时间:%d点%d分", air[j].hour.hour, air[j].hour.minute);
printf("\n\n\t\t剩余票数:%d", air[j].count);
printf("\n\n\t\t票价:%d", air[j].money);
if (i == 1)
{
printf("\n\n\n================================================================================");
}
else
{
printf("\n\n\n\n\n\n================================================================================");
}
loop4: printf("\n\t\t\t(按1显示下一条 按0返回)");
fflush(stdin);
scanf("%d", &n);
switch (n)
{
case 1:
system("cls");
if (em1[k].state == 0)
{
printf("\n\t\t\t\t\t\t\t\t\t管理员");
}
else
{
printf("\n\t\t\t\t\t\t\t\t\t员工");
}
printf("\n________________________________________________________________________________");
break;
case 0:
system("cls");
goto loop1;
break;
default:
system("cls");
if (em1[k].state == 0)
{
printf("\n\t\t\t\t\t\t\t\t\t管理员");
}
else
{
printf("\n\t\t\t\t\t\t\t\t\t员工");
}
printf("\n________________________________________________________________________________");
printf("\n\n\n\n\n\n\n\t\t\t\t您的输入有误!");
printf("\n\n\n\n\n\n\n\n\n\n\n================================================================================");
goto loop4;
}
}
}
if (i == 0)
{
printf("\n\n\n\n\n\n\n\t\t\t没有找到该天的航班信息!!\n\n\n\n");
}
else
{
printf("\n\n\n\n\n\n\n\n\t\t\t查询已到末尾,没有下一条信息!!\n\n\n\n\n\n");
}
printf("\n\n\n\n================================================================================");
printf("\n\t\t\t\t(按任意键返回)");
fflush(stdin);
n=getch();
system("cls");
goto loop1;
break;
case 0: //返回
goto loop5;
break;
default: //输入错误
system("cls");
if (em1[k].state == 0)
{
printf("\n\t\t\t\t\t\t\t\t\t管理员");
}
else
{
printf("\n\t\t\t\t\t\t\t\t\t员工");
}
printf("\n________________________________________________________________________________");
printf("\n\n\n\n\n\n\n\t\t\t\t您的输入有误!");
printf("\n\n\n\n\n\n\n\n\n\n\n================================================================================");
printf("\n\t\t\t\t(按任意键返回)");
fflush(stdin);
n=getch();
system("cls");
goto loop1;
}
fclose(f);
loop5: printf("\n");
}
// // // // // // // // // // 修改密码信息 // // // // // // // // // //
void changepwd(emploe em1[10], int k)
{
FILE *f;
int i;
emploe em2[10];
static char password1[10], password2[10], ch;
system("cls");
if (em1[k].state == 0)
{
system("color 89");
printf("\n\t\t\t\t\t\t\t\t\t管理员");
}
else
{
system("color 79");
printf("\n\t\t\t\t\t\t\t\t\t员工");
}
printf("\n________________________________________________________________________________");
loop1: printf("\n\n\t\t请输入您的原始密码:");
i = 0;
while ((ch = getch()) != 13)
{
if (i != 0 || ch != '\b' )
{
if (ch == '\b')
{
putchar('\b');
putchar(' ');
putchar('\b');
i--;
}
else
{
password1[i] = ch;
putchar('*');
i++;
}
}
}
password1[i] = '\0';
if (strcmp(password1, em1[k].pwd) != 0)
{
system("cls");
if (em1[k].state == 0)
{
printf("\n\t\t\t\t\t\t\t\t\t管理员");
}
else
{
printf("\n\t\t\t\t\t\t\t\t\t员工");
}
printf("\n________________________________________________________________________________");
printf("\n\n\t\t您的原始密码输入有误!!");
goto loop1;
}
printf("\n\n\t\t请输入您的新密码:");
i = 0;
while ((ch = getch()) != 13)
{
if (i != 0 || ch != '\b' )
{
if (ch == '\b')
{
putchar('\b');
putchar(' ');
putchar('\b');
i--;
}
else
{
password1[i] = ch;
putchar('*');
i++;
}
}
}
password1[i] = '\0';
printf("\n\n\t\t请再次输入您的密码:");
i = 0;
while ((ch = getch()) != 13)
{
if (i != 0 || ch != '\b' )
{
if (ch == '\b')
{
putchar('\b');
putchar(' ');
putchar('\b');
i--;
}
else
{
password2[i] = ch;
putchar('*');
i++;
}
}
}
password2[i] = '\0';
if (strcmp(password1, password2) != 0)
{
system("cls");
if (em1[k].state == 0)
{
printf("\n\t\t\t\t\t\t\t\t\t管理员");
}
else
{
printf("\n\t\t\t\t\t\t\t\t\t员工");
}
printf("\n________________________________________________________________________________");
printf("\n\n\t\t您两次输入的密码不一致!!");
goto loop1;
}
if ((f = fopen("pwd.dat", "r")) == NULL)
{
printf("File Can't be find!\n");
}
else
{
fread(&em2, sizeof(em2), 1, f);
}
fclose(f);
if ((f = fopen("pwd.dat", "w+b")) == NULL)
{
printf("File Can't be find!\n");
}
else
{
strcpy(em2[k].pwd, password1);
// m = ftell(f);
// printf("%d", m);
fwrite(&em2, sizeof(em2), 1, f);
}
fclose(f);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -