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

📄 stu_info_7.8.c

📁 linux 下的学生管理系统 非常值得学习的不可或缺的资源!!!!
💻 C
📖 第 1 页 / 共 4 页
字号:
***返回值:无
*****************************************************************/
void AddName() //姓名
{
	char tempname[100];
	int i,len,f=0;
	do{	
		ClearMessage();
		Gotoxy(0,19);
		printf("Please Input len:1-20 a-z or A-Z alpha. <example:zhang san>");	
		Gotoxy(40,8);
		len=GetString(tempname,20);
		Left_Right(tempname);
		len = strlen(tempname);
		if(len==0)
		{
			ClearMessage();
			Gotoxy(0,19);
			printf("Error NULL!Please enter again!");
			getch();
			continue;
		}		
		for(i=0;i<len;i++)
		{
			if(!(isalpha(tempname[i])||tempname[i]==' ')) //判断是不是字母
			{
				ClearMessage();
				Gotoxy(0,19);
				printf("Error!Input illegal char,Please enter again.");
				getch();
				Gotoxy(40,8);
				printf("%*s",40," ");
				break;
			}
		}
		if(i>=len)	
			break;
	}while(1);
	Gotoxy(40,8);
	printf("%*s",40," ");
	Gotoxy(40,8);
	printf("%s",tempname);
	strcpy(data.name,tempname);
	//strcpy(stu_link.studate.name,tempname);
}
/*****************************************************************
***函数名:AddAge
***参数:无
***功能:判断非法字符
***返回值:无
*****************************************************************/
void AddAge() 
{
	int i=0,len,k=0;
	char tempage[40];
	do
	{
		i=0;
		Gotoxy(40,9);
		ClearMessage();
		Gotoxy(0,19);
		printf("Please Input <10-20> digit. <example:15>");	
		Gotoxy(40,9);
		len=GetString(tempage,2);
		if(len==0)
		{
			ClearMessage();
			Gotoxy(0,19);
			cprintf("Error!age is NULL!Please Input age<10-20>.");
			continue;
		}
		for(i=0;i<len;i++)
		{
			if(!(isdigit(tempage[i])))
			{
				ClearMessage();
				Gotoxy(0,19);
				cprintf("Error!Input illegal int.Please Input age<10-20>.");
				getch();
				Gotoxy(40,9);
				printf("%*s",40," ");
				Gotoxy(40,9);
				tempage[0]='\0';
				break;
			}
		}
		k=atoi(tempage);
		if(k>=10 && k<=20)
		{
			break;
		}
		else
		{
			ClearMessage();
			Gotoxy(0,19);
			cprintf("Error!Please Input age<10-20>.");
			getch();
			Gotoxy(40,9);
			printf("%*s",40," ");
			Gotoxy(40,9);
			tempage[0]='\0';
			continue;
		}
		if(i>=len)	
			break;
		else	
			continue;	
	}while(1);
	Gotoxy(40,9);
	printf("%-d",k);
	data.age=atoi(tempage);
	//stu_link.studate.age=atoi(tempage);
}
/*****************************************************************
***函数名:AddScore
***参数:无
***功能:实现5门成绩输入、判断是否合法
***返回值:无
*****************************************************************/	
void AddScore() 
{	
	char tempscore[7];
	int j,len;
	float k;		
	int i=0;
	Gotoxy(40,10);
	do
	{
		ClearMessage();
		Gotoxy(0,19);
		printf("Please Input <0.0-100.0> digit. <example:100>");			
		Gotoxy(40,10+i);
		len=GetString(tempscore,5);
		if(len==0)
		{
			ClearMessage();
			Gotoxy(0,19);
			printf("Error!age is NULL!Please Input score<0-100>.");
			ClearMessage();
			continue;
		}
		for(j=0;j<len;j++)
		{
			if(!(isdigit(tempscore[j])) || tempscore[j]=='.') //判断是不是数字 或"."
			{
				ClearMessage();
				Gotoxy(0,19);
				printf("Error!Input illegal int.Please Input score<0-100>.");
				getch();
				Gotoxy(40,10+i);
				printf("%*s",40," ");
				Gotoxy(40,10+i);
				tempscore[0]='\0';
				break;
			}
			else
			{
				k=(float)atof(tempscore);
				if(k>=0 && k<=100)
				{
					Gotoxy(40,10+i);
					printf("%.1f",k);
					data.score[i]=(float)atof(tempscore);
					//stu_link.studate.score[i]=(float)atof(tempscore);
					i++;
					break;
				}
				else
				{
					ClearMessage();
					Gotoxy(0,19);
					printf("Error!Please Input score<0-100>.");
					getch();
					Gotoxy(40,10+i);
					printf("%*s",40," ");
					Gotoxy(40,10+i);
					tempscore[0]='\0';
					break;
				}
			}
		}
		if(i>=5)
			break;
		else
			continue;
	}while(1);
	Gotoxy(0,19);
}
/*****************************************************************
***函数名:PrintData
***参数:无
***功能:实现数据打印、分页
***返回值:无
*****************************************************************/	
void PrintData()
{
	int i,page=1,pages=10,totalpages;  //page 页码 pages 每页10条数据 totalpages总页码	
	int x,y;
	char ch;
	system("cls");	
	Gotoxy(28,3);
	printf(PRINTDATA);	
	MakeMenuInfo();	
	Gotoxy(0,0);
	do
	{
		Gotoxy(0,6);
		for(i=6;i<18;i++)  //清除6-17行
		printf("%*s",80," ");
		Gotoxy(0,5);
		printf("%-4s%-21s%-4s%-8s%-8s%-5s%-8s%-10s%-6s%-4s\n",
			"sno","name","age","chinese","english","math","physics","chemistry","total","avg");
		Gotoxy(0,6);
		if(count==0)
		{
			ClearMessage();
			Gotoxy(0,19);
			printf("Error!Data is NULL.");
			printf("Pleased key to continue ...");
			fflush(stdin);
			getch();
			return;
		}
		if(count<=pages)
			totalpages=1;
		else
			if(count%pages==0)
				totalpages=count/pages;
			else
				totalpages=count/pages+1;
		if(totalpages==page) //一页
		{
			for(i=(page-1)*pages;i<count;i++)
			{
				total[i]=stu[i].score[0]+stu[i].score[1]+stu[i].score[2]+stu[i].score[3]+stu[i].score[4];
				avg[i]=(double)total[i]/5.0;
				printf("%-4s%-21s%-5d%-8.1f%-7.1f%-7.1f%-8.1f%-8.1f%-6.1f%-4.1lf\n",stu[i].sno,stu[i].name,stu[i].age,
					stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].score[3],stu[i].score[4],total[i],avg[i]);
			}
		}
		else
		{
			for(i=(page-1)*pages;i<(page-1)*pages+pages;i++)
			{
				total[i]=stu[i].score[0]+stu[i].score[1]+stu[i].score[2]+stu[i].score[3]+stu[i].score[4];
				avg[i]=(double)total[i]/5.0;
				printf("%-4s%-21s%-5d%-8.1f%-7.1f%-7.1f%-8.1f%-8.1f%-6.1f%-4.1lf\n",stu[i].sno,stu[i].name,stu[i].age,
					stu[i].score[0],stu[i].score[1],stu[i].score[2],stu[i].score[3],stu[i].score[4],total[i],avg[i]);
			}
		}
		fflush(stdin);
		do
		{
			Gotoxy(20,17);
			printf("Counts=%d                       Page[%d/%d]",count,page,totalpages);
			Gotoxy(15,16);
			printf("Press [U/u] PageUp%c  [D/d] PageDown%c  [Esc] Back %c:",24,25,27);
			Getxy(&x,&y);
			//[U]/[u] 85/117 [D]/[d] 68/100  [Esc] 27
			ch=getche();
			if(ch=='U' || ch=='u')
			{
				if(page==1)
				{
					ClearMessage();
					Gotoxy(0,19);
					printf("The First one page!");
					getch();
					Gotoxy(x+1,y);
					printf("\b \b");
					continue;
				}
				else
				{
					page--;
					break;
				}
			}
			else if(ch=='d' || ch=='D')
			{
				if(page==totalpages)
				{
					ClearMessage();
					Gotoxy(0,19);
					printf("The Last one page!");
					getch();
					Gotoxy(x+1,y);
					printf("\b \b");
					continue;
				}
				else
				{
					page++;
					break;
				}
			}
			else if(ch==27)
			{
				return;
			}
			else
			{
				ClearMessage();
				Gotoxy(0,19);
				printf("Error!Please enter again");
				getch();
				Gotoxy(x+1,y);
				printf("\b \b");
				continue;
			}
		}while(1);
	}while(1);
}
/*****************************************************************
***函数名:Exit_Save
***参数:无
***功能:退出并询问是否保存数据系统
***返回值:无
*****************************************************************/	
void Exit_Save()
{	
	int x,y;
	if(save_flag==1)
	{
		do
		{
			ClearMessage();
			Gotoxy(0,19);
			printf("Data is not save.Are you save Data(Yes/No/Cancel)?[Y]/[N]/[C]]");
			Getxy(&x,&y);
			Gotoxy(x,y);
			ch=getche();
			getch();
			if(ch=='Y' || ch=='y')
			{
				SaveData();
				break;
			}
			else if(ch=='N' || ch=='n')
			{
				Exit_System();
			}
			else if(ch=='C' || ch=='c')
				return ;
			else
			{
				ClearMessage();
				Gotoxy(0,19);
				printf("Error!Please enter again.");
				getch();
				continue;
			}
		}while(ch=='Y' || ch=='y');
	}
	else
	{
		Exit_System();
	}
}
/*****************************************************************
***函数名:Exit_System
***参数:无
***功能:退出系统
***返回值:无
*****************************************************************/	
void Exit_System()
{
	do
	{
		ClearMessage();
		Gotoxy(0,19);
		printf("Are you exit system(Yes/No/Cancel)?[Y]/[N]/[C]]");
		ch=getche();
		getch();
		if(ch=='Y' || ch=='y')
		{
			ClearMessage();
			Gotoxy(0,19);
			printf("Thanks You this system!");
			exit(0);
		}
		else if(ch=='N' || ch=='n')
		{
			ClearMessage();
			Gotoxy(0,19);
			printf("Pleased key to continue ...");
			getch();
			return ;
		}
		else if(ch=='C' || ch=='c')
		{
			return ;
		}
		else
		{
			ClearMessage();
			Gotoxy(0,19);
			printf("Error!Please enter again.");
			getch();
			continue;
		}
	}while(1);	
}
/*****************************************************************
***函数名:SearchData
***参数:无
***功能:实现学号与姓名查询
***返回值:无
*****************************************************************/	
void SearchData()
{	
	int i,s,x,y;
	char *Search[]=
	{	"1.sno select:",
		"2.name select:",
		"0.return MenuList:"
	};
	system("cls");
	Gotoxy(32,3);
	printf(SEARCH);	
	MakeMenuInfo();	
	Gotoxy(0,0);
	
	Gotoxy(0,8);
	s=JuZhong(Search,3);	//菜单项--居中显示	
	for(i=0;i<=2;i++)    //打印菜单项
		printf("%*s%s\n",s," ",Search[i]);
	Gotoxy(26,14);
	printf("Please Make a choices[0-2]:");
	Getxy(&x,&y);
	if(count==0)
	{
		ClearMessage();
		Gotoxy(0,19);
		printf("Error!Data is NULL.");
		printf("Pleased key to continue ...");
		fflush(stdin);
		getch();
		return ;
	}
	do
	{
		Gotoxy(x,y);
		ch=getche();
		getch();
		switch(ch)
		{
			case '1':SearchSno();SearchData();break;
			case '2':SearchName();SearchData();break;
			case '0':return;break;
			default:InputError(x,y,ch);continue;
		}		
	}while(!(ch>='0' && ch<='2'));
}
/*****************************************************************
***函数名:SearchSno
***参数:无
***功能:实现学号查询
***返回值:无
*****************************************************************/
void  SearchSno()//学号查询
{
	int x,y,i,j,flag,t;
	char no[5];
	int num,len;// 记录SNO;
	Gotoxy(0,5);
	for(i=5;i<18;i++)  //清除5-17行
		printf("%*s",80," ");
	do
	{
		flag=0;
		fflush(stdin);
		Gotoxy(20,10);
		printf("Please Input select no:");
		Getxy(&x,&y);
		Gotoxy(0,19);
		printf("Please Input 0-9 digit. <example:001>");		
		Gotoxy(x,y);
		gets(no);
		len = strlen(no);
		if(len==0)
		{
			ClearMessage();
			Gotoxy(0,19);
			printf("Error NULL!Please enter again!");
			getch();
			continue;
		}	
		t=atoi(no);
		sprintf(no,"%03d",t);
		Gotoxy(20,10);
		printf("Please wait!The system is searching...");
		Sleep(300);
		for(j=0;j<count;j++)
		{
			if(strcmp(no,stu[j].sno)==0)  //找到记录
			{
				flag=1;
				num=atoi(no);  //把NO转化为INT型
				Gotoxy(0,5);
				for(i=5;i<18;i++)  //清除5-17行
					printf("%*s",80," ");
				Gotoxy(0,5);
				total[j]=stu[j].score[0]+stu[j].score[1]+stu[j].score[2]+stu[j].score[3]+stu[j].score[4];
				avg[j]=(double)total[j]/5.0;
				printf("%-4s%-21s%-4s%-8s%-8s%-5s%-8s%-10s%-6s%-4s\n",
					"sno","name","age","chinese","english","math","physics","chemistry","total","avg");
				printf("%-4s%-21s%-5d%-8.1f%-7.1f%-7.1f%-8.1f%-8.1f%-6.1f%-4.1lf\n",stu[j].sno,stu[j].name,stu[j].age,
					stu[j].score[0],stu[j].score[1],stu[j].score[2],stu[j].score[3],stu[j].score[4],total[j],avg[j]);
				ClearMessage();
				Gotoxy(0,19);
				printf("select ID:%-4d success!",t);
				break;
			}
			else
				continue;
		}
		if(!flag)
		{
			ClearMessage();
			Gotoxy(0,19);
			printf("sorry!not record!Pleased key to continue ...");
			getch();
			break;
		}	
		do
		{
			Gotoxy(8,16);
			printf("Press [U/u] Update  [D/d] Delete  [Y/y] Continue  [Esc] Back:");
			Getxy(&x,&y);
			ch=getche();
			Gotoxy(0,20);
			printf("%*s",80," ");
			if(ch=='U' || ch=='u')
			{
				UpdateData(num,x,y);

⌨️ 快捷键说明

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