⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 piao.c

📁 飞机票的预定系统
💻 C
字号:
#include "bianliang.h"
#define N 10

// // // // // // // // // // 订 票 系 统 // // // // // // // // // // 
void book(emploe em1[10],int k)
{
	FILE *f;
	int i=0,m=-1;
	char hangban[5],n;
	airplane air[N];	
loop1: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);
	  gets(hangban);
	  if ((f = fopen("air.dat", "r")) == NULL)
	  {
		  printf("File Can't be find!\n");
	  }
	  else
	  {
		  fread(&air, sizeof(air), 1, f);
	  }
	  fclose(f);
	  for (i=0;i<N;i++)
	  {
		  if (strcmp(hangban,air[i].num)==0)
		  {
			  printf("\n\n\t航班号\t出发地\t目的地\t   起飞日期\t起飞时间   剩余票数\t票价");
			  printf("\n\t %s\t %s\t %s\t %d年%d月%d日\t%d点%d分      %d\t%d",air[i].num,air[i].start,air[i].finish,air[i].day.year,air[i].day.month,air[i].day.day,air[i].hour.hour,air[i].hour.minute,air[i].count,air[i].money);
			  printf("\n\n\n\t\t你是否要预订该次航班(Y/N)?");
			  fflush(stdin);
			  scanf("%c",&n);
			  switch(n)
			  {
			  case 'y':
			  case 'Y':
				  m=-1;
				  printf("\n\t\t请输入您要预订的机票数量:");
				  fflush(stdin);
				  scanf("%d",&m);
				  if(m<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\n\n\n\n\n\n\t\t\t\t您的数量输入有误!");
					  printf("\n\n\n\n\n\n\n\n\n\n================================================================================");
					  printf("\n\t\t\t\t(按任意键返回)");
					  fflush(stdin);
					  n=getch();
					  system("cls");
					  goto loop1;
				  }
				  if (m > air[i].count)
				  {
					  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您要预定的航班票数不足!!");
					  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;
				  }
				  if(m>=15)
				  {
					  printf("\n\t\t总共 %d 元<打9折>,是否确定(Y/N)?",9*air[i].money*m/10);
					  fflush(stdin);
					  scanf("%c",&n);
				  }
				  else
				  {
					  printf("\n\t\t总共 %d 元<未打折>,是否确定(Y/N)?",air[i].money*m);
					  fflush(stdin);
					  scanf("%c",&n);				  
				  }
				  switch(n)
				  {
				  case 'y':
				  case 'Y':
					  if ((f = fopen("air.dat", "w+b")) == NULL)
					  {
						  printf("File Can't be find!\n");
					  }
					  else
					  {
				//		  fread(&air, sizeof(air),1, f);
						  air[i].count=air[i].count-m;
						  fwrite(&air, sizeof(air),1 ,f);
					  }
					  fclose(f);
					  printf("\n\t\t你的机票购买成功!!");
					  printf("\n\n\n================================================================================");
					  printf("\n\t\t\t\t(按任意键返回)");
					  fflush(stdin);
					  n=getch();
					  system("cls");
					  goto loop4;
					  break;
				  case 'n':
				  case 'N':
					  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================================================================================");
					  printf("\n\t\t\t\t(按任意键返回)");
					  fflush(stdin);
					  n=getch();
					  system("cls");
					  goto loop4;
				  }

//				  printf("\n\n\n\n\n================================================================================");
//				  printf("\n\t\t\t\t(按任意键返回)");
				  break;
			  case 'n':
			  case 'N':
				  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================================================================================");
				  printf("\n\t\t\t\t(按任意键返回)");
				  fflush(stdin);
				  n=getch();
				  system("cls");
				  goto loop4;
			  }
		  }
	  }
	  printf("\n\n\n\n\n\n\n\t\t\t没有找到您要查询的航班!!");
	  printf("\n\n\n\n\n\n\n\n================================================================================");
	  printf("\n\t\t\t\t(按任意键返回)");
	  fflush(stdin);
	  n=getch();
	  system("cls");
loop4:printf(" ");
}



// // // // // // // // // // 退 票 系 统 // // // // // // // // // // 
void refund(emploe em1[10],int k)
{
	FILE *f;
	int i=0,m=-1;
	char hangban[5],n;
	airplane air[N];	
loop1: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);
	  gets(hangban);
	  if ((f = fopen("air.dat", "r")) == NULL)
	  {
		  printf("File Can't be find!\n");
	  }
	  else
	  {
		  fread(&air, sizeof(air), 1, f);
	  }
	  fclose(f);
	  for (i=0;i<N;i++)
	  {
		  if (strcmp(hangban,air[i].num)==0)
		  {
			  printf("\n\n\t航班号\t出发地\t目的地\t   起飞日期\t起飞时间   剩余票数\t票价");
			  printf("\n\t %s\t %s\t %s\t %d年%d月%d日\t%d点%d分      %d\t%d",air[i].num,air[i].start,air[i].finish,air[i].day.year,air[i].day.month,air[i].day.day,air[i].hour.hour,air[i].hour.minute,air[i].count,air[i].money);
			  printf("\n\n\n\t\t你是否要退订该次航班(Y/N)?");
			  fflush(stdin);
			  scanf("%c",&n);
			  switch(n)
			  {
			  case 'y':
			  case 'Y':
				  printf("\n\t\t请输入您要退订的机票数量:");
				  fflush(stdin);
				  scanf("%d",&m);
				  if(m<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\n\n\n\n\n\n\t\t\t\t您的数量输入有误!");
					  printf("\n\n\n\n\n\n\n\n\n\n================================================================================");
					  printf("\n\t\t\t\t(按任意键返回)");
					  fflush(stdin);
					  n=getch();
					  system("cls");
					  goto loop1;
				  }
				  if(m+air[i].count>50)
				  {
					  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\n\t\t\t您的数量输入有误,票数超过最大值!");
					  printf("\n\n\n\n\n\n\n\n\n\n================================================================================");
					  printf("\n\t\t\t\t(按任意键返回)");
					  fflush(stdin);
					  n=getch();
					  system("cls");
					  goto loop1;
				  }
				  if(m>=15)
				  {
					  printf("\n\t\t总共 %d 元,是否确定(Y/N)?",9*air[i].money*m/20);
					  fflush(stdin);
					  scanf("%c",&n);
				  }
				  else
				  {
					  printf("\n\t\t总共 %d 元,是否确定(Y/N)?",air[i].money*m/2);
					  fflush(stdin);
					  scanf("%c",&n);				  
				  }
				  switch(n)
				  {
				  case 'y':
				  case 'Y':
					  if ((f = fopen("air.dat", "w+b")) == NULL)
					  {
						  printf("File Can't be find!\n");
					  }
					  else
					  {
					//	  fread(&air, sizeof(air),1, f);
						  air[i].count=air[i].count+m;
						  fwrite(&air, sizeof(air),1 ,f);
					  }
					  fclose(f);
					  printf("\n\t\t你的机票退订成功!!");
					  printf("\n\n\n================================================================================");
					  printf("\n\t\t\t\t(按任意键返回)");
					  n=-1;
					  fflush(stdin);
					  n=getch();
					  system("cls");
					  goto loop4;
					  break;
				  case 'n':
				  case 'N':
					  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================================================================================");
					  printf("\n\t\t\t\t(按任意键返回)");
					  fflush(stdin);
					  n=getch();
					  system("cls");
					  goto loop4;
				  }

//				  printf("\n\n\n\n\n================================================================================");
// 				  printf("\n\t\t\t\t(按任意键返回)");
				  break;
			  case 'n':
			  case 'N':
				  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================================================================================");
				  printf("\n\t\t\t\t(按任意键返回)");
				  fflush(stdin);
				  n=getch();
				  system("cls");
				  goto loop4;
			  }
		  }
	  }
	  printf("\n\n\n\n\n\n\n\t\t\t没有找到您要查询的航班!!");
	  printf("\n\n\n\n\n\n\n\n================================================================================");
	  printf("\n\t\t\t\t(按任意键返回)");
	  fflush(stdin);
	  n=getch();
	  system("cls");
loop4:printf(" ");
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -