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

📄 main.c

📁 飞机票的预定系统
💻 C
字号:
#include "bianliang.h"
#include "gongneng.h"
#include "xinxi.h"
static emploe em[10];

void main()
{
	FILE *f;
	int i=0,j=0,n=-1;
	static char name[10],password[6],ch;
	if ((f=fopen("pwd.dat","r"))==NULL)		//从文件pwd.dat中读入数据
	{
		printf("File Can't be find!\n");
	}
	else
	{
		fread(&em,sizeof(em),1,f);
		printf("%s,%s,%d,%d,%d",em[0].name,em[0].pwd,em[0].state,em[0].record,em[0].first);
//		printf("\n%s,%s,%d,%d,%d",em[1].name,em[1].pwd,em[1].state,em[1].record,em[1].first);
//		printf("\n%s,%s,%d,%d,%d",em[2].name,em[2].pwd,em[2].state,em[2].record,em[2].first);
//		printf("\n%s,%s,%d,%d,%d",em[3].name,em[3].pwd,em[3].state,em[3].record,em[3].first);
	}
	fclose(f);
	
	printf("\n\n\n\n================================================================================\n"); 
	printf("\n\t\t\t  §欢迎来到同心缘机票预定系统§\n");
	printf("\n\t\t☆ 安全第一 ☆ 服务至上 ☆ 谦逊共勉 ☆ 团结努力 ☆\n\n\t\t\t◎同心有缘◎\t      ◎齐心协力◎\n\n");
	printf("================================================================================\n"); 
	
loop1:system("color 1e");
	  printf("\n\n\n\n\t\t\t请输入用户名:");
	  fflush(stdin);
	  gets(name);
	  if(name[0]=='\0')					//判断是否输入用户名
	  {
		  system("cls");
		  printf("\n\n________________________________________________________________________________");
		  printf("\n\n\n\n\n\t\t\t您没有输入用户名,请重新输入!");
		  goto loop1;
	  }
	  if (strlen(name)>10)				//判断用户名长度
	  {
		  system("cls");
		  printf("\n\n________________________________________________________________________________");
		  printf("\n\n\n\n\n\t\t\t用户名不符合要求,请重新输入!");
		  goto loop1;
	  }
	  for(i=0;name[i]!='\0';i++)		//判断用户名为字母或数字
	  {
		  if(name[i]<48 || (name[i]>57 && name[i]<65) || (name[i]>90 && name[i]<97) || (name[i]>122))
		  {
			  system("cls");
			  printf("\n\n________________________________________________________________________________");
			  printf("\n\n\n\n\n\t\t\t用户名必须是字母或数字!");
			  goto loop1;
		  }
	  }
	  
	  printf("\n\t\t\t请输入您的密码:");
	  i=0;
	  fflush(stdin);
	  while((ch=getch())!=13)
	  {
		  if(i!=0 || ch!='\b' )		//如果当前光标位置到达最开始的地方执行 
		  {		
			  if(ch=='\b')			//如果是退格键
			  { 
				  putchar('\b');	//屏幕往回退一格 
				  putchar(' ');		//输出一个空格键把当前位置的*擦除 
				  putchar('\b');	//回退一格到刚才那个空格的位置 
				  i--;				//光标位置 - 1
			  }
			  else					//如果不是退格键
			  {
				  password[i] = ch; //将passwprd[]数组第i个字符设置为刚读到的密码
				  putchar('*');		//在当前屏幕位置输出一个*
				  i++;				//光标位置 + 1 
			  }
		  }
	  }
	  password[i]='\0';				//字符数组的最后一位为'\0',故要加该语句
	  
	  for (i=0;i<10;i++) 
	  {
		  if ((strcmp(name,em[i].name)==0) && (strcmp(password,em[i].pwd)==0))
		  {
			  em[i].first++;		//登录次数累加
			  em[i].record=1;		//登录状态为1(处于登录中)
			  system("cls");
			  if (em[i].first==1)	//首次登陆
			  {
				  if (em[i].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\n________________________________________________________________________________");
				  printf("\n\n\n\n\t\t\t\t☆!您好  欢迎您!☆");
				  printf("\n\n\n\t\t\t\t ☆您是首次登陆☆");
				  printf("\n\n\n\t\t\t\t ~请修改您的密码~");
				  printf("\n\n\n\n\n\n\n================================================================================");
				  printf("\n\t\t\t\t(按任意键继续)");
				  fflush(stdin);
				  n=getch();
				  changepwd(em,i);
				  printf("\n\n\n\n\t\t您的密码修改成功!");
				  printf("\n\n\n\n\n\n\n\n================================================================================");
				  printf("\n\t\t\t\t(按任意键继续)");
				  fflush(stdin);
				  n=getch();
			  }
			  else					//不是首次登陆
			  {
				  if (em[i].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________________________________________________________________________________");
				  printf("\n\n\n\n\n\n\n\t\t\t\t~~~~~~~~~~~~~~~");
				  printf("\n\t\t\t\t|您已成功登陆!|");
				  printf("\n\t\t\t\t~~~~~~~~~~~~~~~");
				  printf("\n\n\n\n\n\n\n\n\n================================================================================");
				  printf("\n\t\t\t\t(按任意键继续)");
				  fflush(stdin);
				  n=getch();
			  }
			  if (em[i].state==0) 
			  {
				  adgn(em,i);
				  goto loop2;
			  }
			  else
			  {
				  usgn(em,i);
				  goto loop2;
			  }
		  }
	  }
	  system("cls");
	  printf("\n\n________________________________________________________________________________");
	  printf("\n\n\n\n\n\t\t\t用户名或密码错误,请重新输入!");
	  goto loop1;
loop2:printf("多谢您使用本系统,欢迎再次使用!!!\n");
}

⌨️ 快捷键说明

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