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

📄 main.cpp

📁 学生信息管理系统
💻 CPP
📖 第 1 页 / 共 3 页
字号:
		printf("___________________________________\n");
		printf("学生信息添加成功,请按键返回上级菜单...\n");

                save_record("________________________________________________________\n用户 \"添加\" 了学号为: \"",
					data.num,
					"________________________________________________________\n",
					"\" 的学生.添加成功\n");

		system("pause");
		goto a3;
	} /*else if(1 == xuanzhe)*/

    else if(2 == xuanzhe) {
		L=InsList();                 //初始化线性表
		fp = fopen("d:\\student_data.txt","r");
		if(fp == NULL) error_tuichu(ERROR_2);        //模仿异常的抛出
		while(!feof(fp)) {
			fread(&data,sizeof(ElementData),1,fp);   //从文件读取data数据
			Start_List(L,data,&Number);              //文件中读出的数据压进动态链表
		} /*while(!feof(fp))*/
      fclose(fp);
	  if(L->next->next ==NULL) {
		  printf("\a文件为空,不存在学生数据!请按键返回...\n");
		  system("pause");
		  goto a3;
	  }

	  printf("请输入要删除的学生的\"学号\" 或者 \"姓名\":");
	  getchar();
      gets(input_str);
	  printf("寻找中,请稍候....\n");
	  Sleep(300);

	  L1 = L;
	  while(L1->next!=NULL) {
		  L2 = L1;
		  L1=L1->next;
		  if((strcmp(L1->num,input_str)==0) && (strlen(L1->num)==strlen(input_str))){
              L2->next = L1->next;                       //删除链表指定结点
			  free(L1);
			  L_new= InsList();                          //初始化NEW链表			 
			 L1 = L->next;

		    while(L1->next!= NULL) {
				L1=L1->next;
				strcpy(data.num , (*L1).num);
				strcpy(data.name, (*L1).name);
				strcpy(data.yuwen, (*L1).yuwen);
				strcpy(data.shuxue, (*L1).shuxue);
				strcpy(data.englise, (*L1).englise);
				strcpy(data.cplus, (*L1).cplus);
				data.next = L1->next;
                Start_List(L_new,data,&Number); //拓补NEW链表
		} /*while(L1->next!= NULL)*/
            fclose(fp);
		     fp = fopen("d:\\student_data.txt","w");
		    if(fp == NULL) error_tuichu(ERROR_2);        //模仿异常的抛出
			while(L_new->next !=NULL) {
				L_new=L_new ->next;
				strcpy(data.num , (*L_new).num);
				strcpy(data.name, (*L_new).name);
				strcpy(data.yuwen, (*L_new).yuwen);
				strcpy(data.shuxue, (*L_new).shuxue);
				strcpy(data.englise, (*L_new).englise);
				strcpy(data.cplus, (*L_new).cplus);
				data.next = L_new->next;
				fwrite(&data,sizeof(ElementData),1,fp);
			}/*while(L_new->next !=NULL)*/
			L_new = InsList();
			fclose(fp);

			  printf("学号或者姓名为 \" %s \" 的学生已经删除,请按键返回...\n",input_str);
			  system("pause");

                save_record("________________________________________________________\n用户 \"删除\" 了学号或者姓名为: \"",
					data.num,
					"________________________________________________________\n",
					"\" 的学生.删除成功\n");

              L=InsList();                 //初始化线性表
			  goto a3;

		  }/*if((strcmp(L1->num,input_str)==0) && (strlen(L1->num)==strlen(input_str)))*/

		  else if((strcmp(L1->name,input_str)==0) && (strlen(L1->name)==strlen(input_str))){
              L2->next = L1->next;                       //删除链表指定结点
			  free(L1);
			  L_new= InsList();                          //初始化NEW链表			 
			 L1 = L->next;

		    while(L1->next!= NULL) {
				L1=L1->next;
				strcpy(data.num , (*L1).num);
				strcpy(data.name, (*L1).name);
				strcpy(data.yuwen, (*L1).yuwen);
				strcpy(data.shuxue, (*L1).shuxue);
				strcpy(data.englise, (*L1).englise);
				strcpy(data.cplus, (*L1).cplus);
				data.next = L1->next;
                Start_List(L_new,data,&Number); //拓补NEW链表
		} /*while(L1->next!= NULL)*/
            fclose(fp);
		     fp = fopen("d:\\student_data.txt","w");
		    if(fp == NULL) error_tuichu(ERROR_2);        //模仿异常的抛出
			while(L_new->next !=NULL) {
				L_new=L_new ->next;
				strcpy(data.num , (*L_new).num);
				strcpy(data.name, (*L_new).name);
				strcpy(data.yuwen, (*L_new).yuwen);
				strcpy(data.shuxue, (*L_new).shuxue);
				strcpy(data.englise, (*L_new).englise);
				strcpy(data.cplus, (*L_new).cplus);
				data.next = L_new->next;
				fwrite(&data,sizeof(ElementData),1,fp);
			}/*while(L_new->next !=NULL)*/
			L_new = InsList();
			fclose(fp);

			  printf("姓名为 \" %s \" 的学生已经删除,请按键返回...\n",input_str);
			  system("pause");
              L=InsList();                 //初始化线性表
			  goto a3;

		  }/*else if((strcmp(L1->name,input_str)==0) && (strlen(L1->name)==strlen(input_str)))*/
		  else if(L1->next == NULL)
				 break;
		  
	  }/*while(L1 !=NULL)*/
	  printf("对不起,不存在学号或者姓名为 \" %s \" 的学生,请按键返回...\n",input_str);
	  system("pause");
    
		L=InsList();                 //初始化线性表
		goto a3;
	}/*else if(2 == xuanzhe)*/
	return OK;
} /*功能函数3*/

/*功能函数:4*/
int function_4()
{
	system("cls");                                  //清屏
	system("title 管理系统操作记录查看");               //刷新界面名字
 
	printf("\t\t\t   ***欢迎您的使用***\n");
	printf("\t\t    ***系 统 操 作 记 录 查 看***\n");
	printf("\t\t\t\t\tnow time: %s",get_time());   /*通用时间获取语句*/
	system("start D:\\record.txt");
	printf("操作记录已经打开,请您查看,可以作修改.\n");

   system("pause");
   return OK;

}/*功能函数:4*/

/*功能函数:5*/
int function_5()
{
	system("cls");                                  //清屏
	system("title 修改登陆密码");                   //刷新界面名字
	printf("\t\t\t   ***欢迎您的使用***\n");
	printf("\t\t  ***登 陆 密 码 修 改 功 能 菜 单***\n");
	printf("\t\t\t\t\tnow time: %s",get_time());   /*通用时间获取语句*/
 //...................函数原型声明................................
void ok_tuichu();                                  //正常退出函数
void error_tuichu(int error);                      //异常处理函数
//................................................................

//.....................变量声明...................................
FILE *fp;
char input_str[15]={'0'};                          //用户输入变量存放
char get_file[15]={'0'};                           //文件读取变量
int i=0;                                 
//................................................................
fp = fopen("d:\\id.txt","r");
if(fp ==NULL) error_tuichu(ERROR_4);

while(!feof(fp)) {
	get_file[i++] = fgetc(fp)-i;
}/*while(!feof(fp))*/
fclose(fp);

printf("原始密码为 \"");
i = 0;
while(i<3)
printf("%c",get_file[i++]);
printf("******\" ");
putchar(10);

printf("\n请输入新密码(9位),如果不想修改,请按'0'\n>>");
a5:scanf("%s",input_str);

if(strlen(input_str) !=9) {
    if((input_str[0] == '0') && (strlen(input_str)==1)){
		printf("请稍候,正在返回主菜单...");
		Sleep(850);
		return OK;
	}

	system("cls");                                  //清屏
	system("title 修改登陆密码");                   //刷新界面名字
	printf("\t\t\t   ***欢迎您的使用***\n");
	printf("\t\t  ***登 陆 密 码 修 改 功 能 菜 单***\n");
	printf("\t\t\t\t\tnow time: %s",get_time());   /*通用时间获取语句*/
    printf("原始密码为\n>> ");
    i = 0;
    while(i<3)
    printf("%c",get_file[i++]);
    printf("******");
    putchar(10);

	printf("输入的新密码不合要求(必需为9位),请重新输入(如果不想修改,请按'0')\n>>");
	goto a5;
}

fp = fopen("d:\\id.txt","w");
if(fp ==NULL) error_tuichu(ERROR_4);

i=0;
while(i<9) {
	fputc(input_str[i]+i,fp);
	i++;
}
fclose(fp);

printf("\n密码修改成功,修改后的密码为 \"%s\" ,请按键返回主菜单...\n",input_str);

	system("pause");
	for(i=3;i<9;i++)
		input_str[i]='*';
                save_record("________________________________________________________\n用户 \"修改\" 了登陆密码.\n新密码为: \"",
					input_str,
					"________________________________________________________\n",
					"\"\n");

	return OK;
}/*功能函数:5*/

/*功能函数:6*/
int function_6()
{
	system("cls");                                  //清屏
	system("title 查看发行文档 V2.1正式版");                   //刷新界面名字
	printf("\t\t\t   ***欢迎您的使用***\n");

	printf("\t ***student 信息存储系统 V2.1正式版 发行文档***\n");
	char* get_time();                               //时间获取函数声明
	printf("\t\t\t\t\tnow time: %s",get_time());   /*通用时间获取语句*/

	printf("本系统由BHR团队人员独立开发.\n\n");

    printf("<更新部份>:\n");
	printf("1,代码修改:1号功能排序错误BUG已经修改.\n");
    printf("2,进行了代码优化: 添加类似LINUX的启动界面,希望大家喜欢.\n");
	printf("3,系统操作监视: 记录文件已经应用,实时记录您的一举一动,要查看,请按功能4.\n");
	printf("4,对输入数据加进了合法性检查的代码,以保证文件中学生信息的正确性.\n");
	printf("5,初始密码仍为'123456789'.\n");
	printf("6,此次没有对软件作大的更新,代码还是半年前的,呵呵,我太懒了.\n\n");

	printf("最终解释权归华软软件学院 07嵌入式 BHR团队  2008年11月7日\n");

	system("pause");
	return OK;
}

/*  正常退出界面的函数*/
void ok_tuichu()
{
	system("cls");
	system("title 用户退出");
	printf("\t\t\t  ***感谢您使用本系统***\n");
	printf("\t\t\t\t\tnow time: %s",get_time());    /*通用时间获取语句*/
	save_record("\t\t\t用户正常退出系统\n",
		"\t\t\t\t退出时间:",
		"****************************************************************\n",
		get_time());
	void zifu();
    zifu();
                                     
   	system("pause");
	exit(0);  		//嘿嘿,为保险起见,最后再来一次调用exit函数
}

/*不正常退出界面的函数*/
void error_tuichu(int error)
{
	printf("\a");                                  //形成报警
	system("title error....");                      //进入新页面
	system("cls");                                //清屏
	switch(error) {
	case ERROR_1: printf("文件打开失败!请检查文件路径是否正确(是否存在此路径)\n"); 
				  break;
	case ERROR_2: printf("系统找不到系统运行时所支持的student_data.txt数据库文件\n");
		printf("请您检查您的D盘目录,是否存在student_data.txt数据库文件\n");
		          break;
	case ERROR_3: printf("系统找不到操作记录record.txt数据库文件\n");
		          printf("请您检查您的D盘目录,是否存在record.txt数据库文件\n");
		          break;
	case ERROR_4: printf("系统找不到ID记录的数据库文件id.txt,身份信息不能确认\n");
		          printf("请您检查您的D盘目录,是否存在id.txt数据库文件\n");
		          break;
	case ERROR_5: printf("内存空间分配失败.\n");
		          break;
	case ERROR  : printf("密码多次输入错误,本系统不提供无限次的密码尝试!\n");
		          printf("\t\t\t\t~bye bye~\n\n");
		          break;
	default: break;
				         /*......more......*/
		/*添加更多错误信息处理语句,以增加程序健壮性,呵呵,够周到吧*/
	}
	system("pause");
	save_record("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\t\t\t用户对系统操作非法或者系统错误,退出\n",
		"\t\t\t\t退出时间:",
		"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n",
		get_time());
	exit(0);
}

/*姓名条件符合时的链表输出函数*/
void get_ok_name(LinkList L1,char* input_name)
{

printf("%s    %s\t   %s\t %s\t%s\t   %s\n",L1->num,L1->name,L1->yuwen,
         L1->shuxue,L1->englise,L1->cplus);
}


/*记录打印模块*/
void save_record(char *Str_Information1,char *Str_Information2,char *Str_Information3,char *Str_Time)
{
 FILE *fp;
 fp = fopen("d:\\record.txt","a");
 if(fp ==NULL)
	 error_tuichu(ERROR_3);
 fprintf(fp,"%s%s%s%s\n",Str_Information1,Str_Information2,Str_Time,Str_Information3);
  fclose(fp);
}

           /*....more...*/
/*更多函数的实现部分,在此添加,嘿嘿.!.*/


/*字符函数*/
/*没事干,拿团队名字写个艺术字*/
void zifu()
{
	printf("* * * * * * * * * *         * * * *         * * * *    * * * * * * * * *\n");     //第1行
	Sleep(70);
	printf("  * * * * * * * * * *         * *             * *        * *           * *\n");    //第2行
	Sleep(70);
	printf("  * *               * *       * *             * *        * *             * *\n");    //第3行
	Sleep(70);
	printf("  * *               * *       * *             * *        * *               * *\n");    //第4行
	Sleep(70);
	printf("  * *                 * *     * *             * *        * *               * *\n");    //第5行
	Sleep(70);
	printf("  * *                 * *     * *             * *        * *               * *\n");  //第6行
	Sleep(70);
	printf("  * *               * *       * *             * *        * *              * *\n");  //第7行
	Sleep(70);
	printf("  * *               * *       * *             * *        * *             * *\n");  //第8行
	Sleep(70);
	printf("  * *             * *         * *             * *        * *            * *\n");  //第9行 
	Sleep(70);
	printf("  * * * * * * * * *           * * * * * * * * * *        * * * * * * * * * \n");  //第10行 
	Sleep(70);
	printf("  * * * * * * * * *           * * * * * * * * * *        * * * * * * * * *\n");  //第11行
	Sleep(70);
	printf("  * *             * *         * *             * *        * *            * *\n");  //第12行 
	Sleep(70);
	printf("  * *               * *       * *             * *        * *             * *\n");  //第13行
	Sleep(70);
	printf("  * *               * *       * *             * *        * *              * *\n");  //第14行
	Sleep(70);
	printf("  * *                 * *     * *             * *        * *               * *\n");  //第15行
	Sleep(70);
	printf("  * *                 * *     * *             * *        * *               * *\n");  //第16行
	Sleep(70);
	printf("  * *               * *       * *             * *        * *               * *\n");  //第17行
	Sleep(70);
	printf("  * *               * *       * *             * *        * *               * *\n");  //第18行
	Sleep(70);
	printf("  * * * * * * * * * *         * *             * *        * *               * *\n");  //第19行
	Sleep(70);
	printf("* * * * * * * * * *         * * * *         * * * *    * * *               * * *\n");  //第20行	
}

⌨️ 快捷键说明

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