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

📄 studentmanagersystem.c

📁 软件的名称:学生信息管理系统 软件的功能:登录功能、主菜单功能、学生信息录入功能、学生记录的排序功能、查询和删除功能、学生信息打印功能、记录保存功能、记录读取功能、分数统计报表功能和退出功能等。
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "FuncDeclare.h"
#include "link.h"
#include "file.h"
int inforsave = 0;//全局变量,退出系统是如果有信息未保存,inforsave等于1,否则为零
int Sno_count = 10;//记录学生记录数目
student *head=NULL,*last=NULL;
//初始化学生数据
student stu[100]={{"004","nzhipalong",20,10.0,10.0,30.0,40.0,50.0},
				  {"003","gfgdPAdf",21,20.0,20.0,40.0,50.0,60.0},
				  {"002","sfdfdfdf",23,50.0,30.0,70.0,80.0,90.0},
				  {"009","sdpappadf",22,30.0,40.0,50.0,60.0,70.0},
				  {"005","paffs",24,40.0,50.0,60.0,70.0,80.0},
				  {"006","fdfff",23,70.0,70.0,90.0,100.0,100.0}, 
				  {"007","sdfdf",21,60.0,70.0,80.0,90.0,100.0},
				  {"008","swerf",21,60.0,80.0,80.0,90.0,100.0},
				  {"001","sfdf",21,60.0,80.0,80.0,90.0,100.0},
				  {"010","sPwefffddf",21,60.0,80.0,80.0,90.0,100.0}
};
int sign[100][2];
//登录界面
int LoginMenu()
{
	int j;//在界面菜单名称位置起作用
	int inputnumber = 0;
	int chooseerr;
	char name[20],passwd[20];//存放登录名,密码
	char choose[2];//存放Y或者N
	int  namereturn,namelen;
	int  passwdreturn,passwdlen;
	FrameHead(HEADROW,LINE);
	FrameInfo(INFOROW,LINE);
	/*------------------------打印界面名称,菜单选项----------------------*/
	SetXY(24,1);
	for(j=0;j<30;j++)
		printf("*");
	SetXY(24,2);
	printf("*");
	SetXY(35,2);
	printf("Login Menu");
	SetXY(53,2);
	printf("*");
    SetXY(24,3);
	for(j=0;j<30;j++)
	printf("*");
    SetXY(24,6);
	printf("%-10s","Loginname:");
	SetXY(24,10);
	printf("%-10s","Password :");
   /*---------------------------------打印结束------------------------------*/
	SetXY(1,21);
	printf("You have three chances to login ^_^");	
	do
	{
	
	if(inputnumber>3)
	{
		ClearScreen(1,19,78,20);//清楚信息框内容
		SetXY(20,17);
		printf("Do you want to exit system? [Y] || [N]:");
	do
	{
		SetXY(60,17);
		input(choose,1);
		chooseerr=IsExit(choose,60,17);
		if(chooseerr==0)
		{
			break;
		}    
	}while(1);
	if(choose[0]=='y' || choose[0]=='Y')
	{
		ClearScreen(1,17,78,17);//清楚提示是否退出
		ClearScreen(1,19,78,20);//清楚信息框内容
		SetXY(1,19);
		exit(0);
	}
	else
	{
		ClearScreen(1,17,78,17);//清楚提示是否退出
		ClearScreen(1,19,78,20);//清楚信息框内容
		inputnumber=0;
		continue;
		//break;
	}
	}
	inputnumber++;
	SetXY(35,6);
	input(name, 20);
	RomoveLeftBlank(name);
    RomoveRightBlank(name);
    namelen=strlen(name);
	if(namelen<=0)//判断登陆名是否为空
	{
		ClearScreen(1,19,78,20);//清楚信息框内容
		SetXY(1,19);
		printf("Loginname cannot be empty!");
		ClearScreen(35,6,78,6);
		continue;  
	}
	else 
	{
		ClearScreen(1,19,78,20);//清楚信息框内容
		SetXY(35,10);
		inputpasswd(passwd,20);
		RomoveLeftBlank(passwd);
		RomoveRightBlank(passwd);
		passwdlen=strlen(passwd);
		while(passwdlen<=0)//判断登陆密码是否为空
		{
			ClearScreen(1,19,78,20);//清楚信息框内容
			SetXY(1,19);
			printf("Password Must Not Be Null!");
			ClearScreen(35,10,78,10);
			SetXY(1,19);
			printf("Please input Passwd");
			SetXY(35,10);
			inputpasswd(passwd,20);
			passwdlen=strlen(passwd);
		}
	}
    namereturn=strcmp(USERNAME,name);
	passwdreturn=strcmp(PASSWD,passwd);
	if(namereturn==0 && passwdreturn==0)
	{
		ClearScreen(1,19,78,20);//清楚信息框内容
		return 0;
	}
	else
	{
		ClearScreen(1,19,78,20);//清楚信息框内容
		SetXY(1,19);
		printf("Login Fail,Please Login Again!...enter any key to continue");
		getch();
		ClearScreen(1,19,78,20);
		ClearScreen(35,6,78,6);
		ClearScreen(35,10,78,10);
	}	
	}while(1);
}

//添加学生记录
int EnterAddStuInfo()
{
	extern inforsave;
	extern Sno_count;
	student *p;
	int nameerr,ageerr,matherr,chinerr,engerr,phyerr,chemerr,chooseerr;
	char sno[4],name[25],age[4],math[8],chin[8],eng[8],phy[8],chem[8];
	char choose[2];
	int  re_input=0;//按ESC退出当前界面
	int  makesno;
	p=(student *)malloc(LEN);
   /*---------------------------打印菜单界面名称--------------------------*/
    SetXY(32,2);
	printf("Add Student Info");
	/*---------------------------打印结束--------------------------*/
	SetXY(15,5);
	printf("%10s","Sno: ");
	//MakeSno(sno,25,5);
	Make_Sno(sno);
	puts(sno);

    SetXY(35,5);
	printf("%10s","Name: ");
	SetXY(15,7);
	printf("%10s","Age: ");
	SetXY(35,7);
	printf("%10s","Math: ");
	SetXY(15,9);
	printf("%10s","Chinese: ");	
	SetXY(35,9);
	printf("%10s","English: ");	
	SetXY(15,11);
	printf("%10s","Physics: ");
	SetXY(35,11);
	printf("%10s","Chemistry:");
    ClearScreen(1,19,78,20);//清楚信息框内容
	//输入姓名
	do
	{   
		DrawInputFrame(COLOR,45,5,25);
		SetXY(45,5);
        SetTextCorlor(COLOR);
		re_input=input(name,22);
		if(re_input==1)
			{	SetTextCorlor(TEXTCOLOR);return 0;}
	    SetTextCorlor(TEXTCOLOR);
	    nameerr=NameErrorTip(name,15,5,1);
		if(nameerr==0)
			break;
	}while(1);	
	
    DrawInputFrame(COLOR,45,5,25);
	SetXY(45,5);
	puts(name);
	SetTextCorlor(TEXTCOLOR);
	 ClearScreen(1,19,78,20);   //清楚信息框内容
	//输入年龄
	do
	{	SetXY(25,7);
		DrawInputFrame(COLOR,25,7,8);
		SetTextCorlor(TEXTCOLOR);
		SetXY(35,7);
		printf("%10s","Math: ");
		SetXY(25,7);
        SetTextCorlor(COLOR);
		re_input=0;
		re_input=input(age,3);
		if(re_input==1)
			{	SetTextCorlor(TEXTCOLOR);return 0;}
		SetTextCorlor(TEXTCOLOR);
		ageerr=AgeErrorTip(age,15,5);
		if(ageerr==0)
			break;
	}while(1);
	DrawInputFrame(COLOR,25,7,8);
	SetXY(25,7);
    printf("%d",atoi(age));
    SetTextCorlor(TEXTCOLOR);
	ClearScreen(1,19,78,20);//清楚信息框内容
	//输入数学成绩
	do
	{
		SetXY(35,7);
		printf("%10s","Math: ");

		DrawInputFrame(COLOR,45,7,25);
		SetXY(45,7);
        SetTextCorlor(COLOR);
		re_input=0;
		re_input=input(math,7);
		if(re_input==1)
			{	SetTextCorlor(TEXTCOLOR);return 0;}
		SetTextCorlor(TEXTCOLOR);
		matherr=ScoreErrorTip("Math",math,45,7,25);
		if(matherr==0)
			break;
	}while(1);
	DrawInputFrame(COLOR,45,7,25);
	SetXY(45,7);
	printf("%-5.1f",(float)atof(math));
	SetTextCorlor(TEXTCOLOR);
	ClearScreen(1,19,78,20);//清楚信息框内容
	//输入语文成绩
	do
	{
		SetXY(25,9);
		DrawInputFrame(COLOR,25,9,8);  
		SetTextCorlor(TEXTCOLOR);

		SetXY(35,9);
		printf("%10s","English: ");

		SetXY(25,9);
		SetTextCorlor(COLOR);
		re_input=0;
		re_input=input(chin,7);
		if(re_input==1)
			{	SetTextCorlor(TEXTCOLOR);return 0;}
		SetTextCorlor(TEXTCOLOR);
		chinerr=ScoreErrorTip("Chinese",chin,25,9,10);
		if(chinerr==0)
			break;
	}while(1);
    DrawInputFrame(COLOR,25,9,8);
	SetXY(25,9);
	printf("%0.1f",(float)atof(chin));
	SetTextCorlor(TEXTCOLOR);
	ClearScreen(1,19,78,20);//清楚信息框内容
	//输入英语成绩
	do
	{
		SetXY(35,9);
		printf("%10s","English: ");

		DrawInputFrame(COLOR,45,9,25);
		SetXY(45,9);
        SetTextCorlor(COLOR);
		re_input=0;
		re_input=input(eng,7);
		if(re_input==1)
			{	SetTextCorlor(TEXTCOLOR);return 0;}
		SetTextCorlor(TEXTCOLOR);
		engerr=ScoreErrorTip("English",eng,45,9,25);
		if(engerr==0)
			break;
	}while(1);
	DrawInputFrame(COLOR,45,9,25);
	SetXY(45,9);
	printf("%0.1f",(float)atof(eng));
	SetTextCorlor(TEXTCOLOR);
	ClearScreen(1,19,78,20);//清楚信息框内容
	//输入物理成绩
	do
	{
		SetXY(35,11);
		printf("%10s","Chemistry:");

		DrawInputFrame(COLOR,25,11,8);
		SetXY(25,11);
        SetTextCorlor(COLOR);
		re_input=0;
		re_input=input(phy,7);
		if(re_input==1)
			{	SetTextCorlor(TEXTCOLOR);return 0;}
		SetTextCorlor(TEXTCOLOR);
		phyerr=ScoreErrorTip("Physics",phy,25,11,8);
		if(phyerr==0)
			break;
	}while(1);
	DrawInputFrame(COLOR,25,11,8);
	SetXY(25,11);
	printf("%0.1f",(float)atof(phy));
	SetTextCorlor(7);
	ClearScreen(1,19,78,20);//清楚信息框内容
	//输入化学成绩
	do
	{
		DrawInputFrame(COLOR,45,11,25);
		SetXY(45,11);
        SetTextCorlor(COLOR);
		re_input=0;
		re_input=input(chem,7);
		if(re_input==1)
			{	SetTextCorlor(TEXTCOLOR);return 0;}
		SetTextCorlor(TEXTCOLOR);
		chemerr=ScoreErrorTip("Chemistry",chem,45,11,25);
		if(chemerr==0)
			break;
	}while(1);
	DrawInputFrame(COLOR,45,11,25);
	SetXY(45,11);
	printf("%0.1f",(float)atof(chem));
	SetTextCorlor(TEXTCOLOR);
	ClearScreen(1,19,78,20);//清楚信息框内容
	SetXY(8,17);
	printf("Do you want to save student information? [Y] || [N]:");
	do
	{
		SetXY(61,17);
		input(choose,1);
		chooseerr=IsAdd(choose,24,5);
		if(chooseerr==0)
		{
			break;
		}    
	}while(1);

	if(choose[0]=='y' || choose[0]=='Y')
	{
		strcpy(p->sno,sno);
		strcpy(p->name,name);
		// 给指针数据成员赋值
		p->age=atoi(age);
		p->score[0]=(float)atof(math);
		p->score[1]=(float)atof(chin);
		p->score[2]=(float)atof(eng);
	    p->score[3]=(float)atof(phy);
		p->score[4]=(float)atof(chem);
		p->next=NULL;
		//增加结点
		InsertLinkByLast(&head,p);
		makesno=atoi(sno);
		sign[makesno-1][1]=1;
		inforsave=1;
		Sno_count++;	
		SetTextCorlor(TEXTCOLOR);
		free(p);
		ShowMessge("Save successfully!...enter any key to continue");
		getch();
		//SetTextCorlor(TEXTCOLOR);
		//CleanMenuInfo();
		return 0;
		}
	else
	{
		inforsave=0;
		//CleanMenuInfo();
		//SetTextCorlor(TEXTCOLOR);
		return 0;
	}
}

//查询学生信息界面
int SearchStuInfo()
{
	int searchsno;
	int searchname;
	int value;
	char ch[1];
	/*-------打印界面名称,菜单选项-------*/
	do
	{
		SetXY(30,2);
	printf("Search Student Info");

    SetXY(24,5);
	printf("1........Search by StudentID");
	SetXY(24,6);
	printf("2........Search by StudentName");
	SetXY(24,7);
	printf("0........Back to MainMenu");
    SetXY(24,17);
	printf("please enter your choose[0-2]:");	
	/*----打印结束------*/

	SetXY(54,17);
    input(ch,1);//定长输入
	value=MainMenuValidate(ch,'0','2');//调用主菜单验证函数
	if (value==1)
	{		
		EmptyMessage(54,17,78,17);//打印空操作提示
	}	
	else if(value==2)
	{
		InvalidMessage(54,17,78,17);//打印非法字符提示
	}
	else if(value==3)
	{
		ExceedMessage(54,17,78,17);//打印超出范围提示
	}
	else if(value==0)
	{
		switch(ch[0])
			{
				case '1':	searchsno=SearchSno_Result(&head,24,9,1);
						     break;
				case '2':	searchname=SearchName_Result(&head,24,9,2);
						     break;
				case '0':	return 0;			     
			}
		}	
	}while(1);
}

//学生信息排序界面
int SortStuInfo()
{

⌨️ 快捷键说明

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