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

📄 mis_sms(finish).c

📁 学生信息管理系统 代码量在3000左右。原创作品。(内附程序流程图)
💻 C
📖 第 1 页 / 共 5 页
字号:
						}
						
						if (key == _PAGEDOWN)
						{	
							GoToXY(k_x-2,k_y);
								printf("  ");
								data=0;
								
							if (q==printtail)
							{
								GoToXY(1,19);
								printf("Alert, This is last record");
								Sleep(500);
								Clear(1,19);								
								break;
							}
							row++;
							q=q->next;		
							if(row==10 )//|| q==pagecount[i+1])
							{
								i++;
								row=0;
							}

							break;
						}
						if (key == _PAGEUP)
						{						
							GoToXY(k_x-2,k_y);
								printf("  ");
								data=0;
							
							if (q==printhead->next)
							{
								GoToXY(1,19);
								printf("Alert, This is first record");
								Sleep(500);
								Clear(1,19);
								
								break;
							}
							q=q->pre;
							row--;	
								if(row==-1)// ||q==pagecount[i-1])
							{
								i--;
								row=9;
							}
							break;
						}
						
						if (key == _ESC)
						{
							exitflag=1;
							ClearDisplay(1,1);							
							PrintRecordFrame(sign);
							Clear(1,16);
							q = pagecount[i];
							//row=0;							
							break;
						}
						
						else
						{
							GoToXY(1,19);
							printf("Alert ,Only admit [up]/[down]/[ESC] ");
							Sleep(700);
							Clear(1,19);
							continue;
						}						
					}
					if (key == _ESC)
						break;
					continue;			 
				}			
			
			}
			if (exitflag==1)
			{
				break;
			}
			
			if (key == _ESC)
			{
				q=head->next;
				while(q)
				{
					for (j=0;j<k;j++)
					{
						if (strcmp(q->data.sno,&txt[j])==0)
						{
							if (q==tail)
							{
								tail=tail->pre;							
							}
							else
							{
							q->pre->next=q->next;
							q->next->pre=q->pre;
							}							
						}	
					}
					q=q->next;
				}
				return -1;
			}			
			else 
			{
				GoToXY(1,19);
				printf("Alert ,Only admit [up]/[down]/[pageup]/[pagedown]/[enter]/[delete] ");
				Sleep(1000);
				Clear(1,19);
				GoToXY(xx,yy);
			}
		}				
	}	
}

void FindFailAlert(char *str,char *temp)
{
	Clear(1,11);
	GoToXY(1,19);
	if (strcmp(str,"sno")==0)	
	printf("The student of No.<%s>: can't find        ",temp);
	else
	{
	printf("The student Name <%s>: can't find        ",temp);
	}
	GoToXY(20,11);
	printf(" [1]. change the keywords search again!!!");
	GoToXY(20,12);
	printf(" [2]. previous page!!!                   ");
	GoToXY(20,13);
	printf(" [0]. cancel ,back to main menu!!!       ");
	GoToXY(20,15);
	printf("Please make a choise[0-2]");
}

/*
*************************************************************
* 函数描述:学生信息查询函数
* 输入参数:无
* 返回值  :无
*************************************************************
*/
int SearchData()
{
	int key,flag=-1,key_1,key_2,flag_2;
	Stu_Lnode *q,*searchpoint;
	char temp[21];	 
	int y;
	temphead = temptail = (Stu_Lnode *)malloc(sizeof(Stu_Lnode));
	ClearDisplay(1,1);
	PrintTopBorder();
	PrintTitle("Search student");		
		if (tail->data.sno == NULL)
		{
			GoToXY(1,19);
			printf("Sorry ,No data in the record !!!");
			GoToXY(26,13);		
			printf("Press any key to back main menu");
			GetchKey();
			Clear(1,19);
			Clear(1,13);
			return -1;
		}	
		GoToXY(24,11);
		printf("[1] .Search by  No.");
		GoToXY(24,12);
		printf("[2] .Search by  Name");
		GoToXY(24,13);
		printf("[0] .Cancel , back to main menu");
		GoToXY(24,15);
		printf("Please make a choise[0-4]");
		while(1)
		{
			key = GetchKey();

			if (key == _0 || key == _1 || key == _2|| key == _ESC)
			{
				break;
			}
			else
			{
				PrintAlert(4);
				GoToXY(49,15);
			}
		}	
    if (key == _0|| key == _ESC)
		return -1;
	if (key == _1)
	{
search_by_number:   //输入关键字,查找学号
		do{
		    ClearAll();
			PrintTitle("Search by No.");			
			if (flag==0)
			{
				GoToXY(1,19);
				printf("Sorry , this keyword invalid");
				GoToXY(10,11);
				printf("Please input a keywords again [001-999]:");
			}
			else
			{
				GoToXY(15,11);
				printf("Please input a keywords [001-999]:");
			}
			if (GetString(temp,8)==-1)
				{	
				if (atoi(p->data.sno)==1)
				head=NULL;
			return -1;
		}
		
			if(!IdentifyDigit(temp))  //如果关键字不合法
			{
				flag=0;
			}
			else 
				flag=1;			
		}while(flag!=1);

		q=head->next;
		 
		while (q->data.sno!=NULL)
		{			
			if (atoi(q->data.sno) == atoi(temp))
			{	
				searchpoint = (Stu_Lnode *)malloc(sizeof(Stu_Info));
				flag=-1;
				searchflag=1;
				memcpy(&searchpoint->data,&q->data,sizeof(Stu_Info));
				temptail->next = searchpoint;
				searchpoint->pre = temptail;
				temptail = searchpoint;
				temptail ->next = NULL;				
			}
			q=q->next;
		}				
		if (flag!=-1)
		{
			do{
			FindFailAlert("sno",temp);
			key_1=GetchKey();
			Clear(1,19);
			if (key_1 == _1)
			{
				goto search_by_number; //重新输入关键字
			}
			if (key_1 == _2)
				return 0; 
			if (key_1 == _0|| key == _ESC)
				return -1;
			else 
			{	
				PrintAlert(2);				
			}

			}while(key_1 != _1 && key_1 != _2 && key_1 != _0);
		}
		if (flag==-1)
		{
			while (1)
			{
				flag=PrintInfo(0);
				if (flag==-1)
				{
					searchflag = 0;	
					return 0;			

				}
			}
		}
		searchflag = 0;		
	}//end if (key==_1)

	if (key == _2)
	{
search_by_name:
		flag=0;
		ClearAll();
		PrintTitle("Search by Name.");
		GoToXY(15,11);
		printf("Please input a keywords:");
		gets(temp);
		q=head->next;	
		while (q->data.sno!=NULL)
		{
			if (strstr(strlwr(strdup(q->data.sname )),strlwr(strdup( temp ))))
			{	
				searchpoint=(Stu_Lnode *)malloc(sizeof(Stu_Info));
				flag=-1;
				searchflag=1;
				memcpy(&searchpoint->data,&q->data,sizeof(Stu_Info));
				temptail->next = searchpoint;
				searchpoint->pre = temptail;
				temptail = searchpoint;
				temptail ->next = NULL;
			}
			q=q->next;
		}
		if (flag==-1)
		{
			while (1)
			{
				flag=PrintInfo(0);
				if (flag==-1)
				{
					searchflag = 0;				
					return 0;
				}
			}
		}
		if (flag!=-1)
		{
			do{
			FindFailAlert("sname",temp);
			key_1=GetchKey();
			Clear(1,19);
			if (key_1 == _1)
			{
				goto search_by_name; //重新输入关键字
			}
			if (key_1 == _2)
				return 0; 
			if (key_1 == _0|| key == _ESC)
				return -1;
			else 
			{	
				PrintAlert(2);				
			}

			}while(key_1 != _1 && key_1 != _2 && key_1 != _0);
		}
		
	}	
	return 0;
}

int ExitConfirm()
{
	int key;
	int flag;
	PrintTitle(" Exit ");
	ClearDisplay(1,1);
	//exitconfirm:
	while(1)
	{	
		PrintRectangle(30,3,"Please confirm");
		if(filedatachange!=1)
		{
			GoToXY(30,10);
			printf("     [0].Continue");
			GoToXY(30,9);
			printf("     [1].Back Menu");
			GoToXY(28,13);
			printf(" Please make a choise[0-1]");
		}
		
		if(filedatachange==1)
		{
			GoToXY(30,11);
			printf("     [0].Continue");				
			GoToXY(30,9);
			printf("     [1].Save Record");
			GoToXY(30,10);
			printf("     [2].Back Menu List");
			GoToXY(1,19);
			printf(" Alert, Record no save!!!");
			GoToXY(28,13);
			printf(" Please make a choise[0-2]");
		}	
		while(1)
		{
			key=GetchKey();
			if (key == _0)
				exit(0);
			if (key == _1)
			{
				if (filedatachange!=1)
					return -1;
				if (filedatachange==1)
				{
					exitflag=1;
					flag=SaveData();
					if (flag==-1)
						return -1;					
				}
				break;	
			}
			if(key==_ESC)
				return -1;
			if (key == _2 && filedatachange==1)
				return -1;
			else 
			{
				PrintAlert(1);
				if(filedatachange==1)
				{
					GoToXY(1,19);
					printf(" Alert, Record no save!!!");
				}
				GoToXY(28+strlen(" Please make a choise[0-2]"),12);
				break;				
			}			
		}//end while		
	}//end while
}

int StatTopGrade(int k,int grade)
{
	int i,count=0,j;
	char *str,str_total[5],str_total_max[5];
	Stu_Lnode *q,*q2,*max;
	Stu_Lnode *stemp; 
	temphead = temptail = (Stu_Lnode *)malloc(sizeof(Stu_Lnode));
	q=head;

	if(q==NULL)
	{
		return EMPTY;
	}
	
	q=head->next;	
	
	while(1)
	{			
		stemp = (Stu_Lnode *)malloc(sizeof(Stu_Info));						
		memcpy(&stemp->data,&q->data,sizeof(Stu_Info));
		temptail->next = stemp;
		stemp->pre = temptail;
		temptail = stemp;
		temptail ->next = NULL;	
		if(q==tail)
			break;
		q=q->next;
		
	}	
	q2 = max = temphead->next;
	q=max->next;
	while(1)
	{	
		while(1)
		{	
			CalculateTotal(max,str_total_max);		
			CalculateTotal(q,str_total);
		
			if(
				(k==1 && atof(max->data.schi) <= atof(q->data.schi))				
				||
				(k==2 && atof(max->data.seng) <= atof(q->data.seng))
				||
				(k==3 && atof(max->data.smath)<= atof(q->data.smath))
				||
				(k==4 && atof(max->data.spho) <= atof(q->data.spho))
				||
				(k==5 && atof(max->data.sche) <= atof(q->data.sche))
				||
				(k==6 && atof(str_total_max) <= atof(str_total))
				)
			
				max=q;						
		if(q==temptail)
		break;
			
			q=q->next;
		}	
		
		count++;
		if(count >grade)
		{
			if(q2==temptail)
				break;				
			if(max==q2)
			{
				statflag=1;
				temptail=max;
				return 0;
			}
			q2=q2->next;	
		}
		
		stemp = (Stu_Lnode *)malloc(sizeof(Stu_Info));		
		memcpy(stemp,max,sizeof(Stu_Info));
		memcpy(max,q2,sizeof(Stu_Info));
		memcpy(q2,stemp,sizeof(Stu_Info));				
		
		
		if(count >=grade)
		{
			max=q2;
			q=max->next;			

		}
		else
		{
			q2=q2->next;
			max=q2;
			if(max==temptail)
				break;
			q=max->next;
		}
		
		if(q == temptail)
			break;
			
	}
	statflag=1;
}




int menu(int k)
{
	int flag=0;
	switch(k)
	{	
	case _1 :
		do{
			flag=AddInfo();
		}while (flag!=-1);
		break;
	case _2 :
		do{
			flag=Sort(1);
		}while (flag!=-1);
		break;
	case _3 :
		while(1)
		{
			flag=PrintInfo(0);
			if (flag==-1)
			{
				PrintTopBorder();
				Clear(1,16);
				break;
			}				
		}		
		break;
	case _4 :
		flag=SaveData();
		break;
	case _5 :
		do{
			flag=LoadData();
		}while (flag!=-1);
		break;
	case _6 :
		do{
			flag=SearchData();
		}while (flag!=-1);
		break;				
	case _7 :
		do{
			flag=Sort(2);
		}while (flag!=-1);
		break;
	}	
    if (flag==-1)
		return -1;
	return 0;
}


void ScreenBfferFix()
{
	COORD pos;
	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_SCREEN_BUFFER_INFO bInfo;	
	GetConsoleScreenBufferInfo( hOut, &bInfo );	
	pos.Y=24;
	SetConsoleScreenBufferSize(hOut,pos);
}

void FontColerFix()
{
	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	WORD Color = FOREGROUND_WHILE | BACKGROUND_BLUE;
	SetConsoleTextAttribute(hOut,Color);

}

void SetTitle()
{
	SetConsoleTitle ("Welcome to Student Information Manage System....");
}

void main()
{   
	
    int key,flag=0;
	//CONSOLE_FONT_INFO bFont;
	FontColerFix();
	SetTitle();
	PrintFrame();	
mainmenu:
	
	ClearAll();
	PrintTitle("MAIN LIST");
	PrintMenu();
	while(1)
	{
		key=GetchKey();
		if (key>'0' && key<='7')
		{
			flag=menu(key);
			if (flag==-1)
				goto mainmenu;
		}    
		if (key == '0' || key == _ESC )
		{
			flag=ExitConfirm();
			if (flag== -1)
				goto mainmenu;			
		}		
		else
		{
			GoToXY(1,19);
			printf("Alert,Choise range between [0-7]");	
			GoToXY(1,20);
			printf("Press any to continue");		
			key=GetchKey();		
			ClearMassage();
			GoToXY(55,11);
			continue;
		}	
	}
}	 

⌨️ 快捷键说明

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