学生管理系统c++

#include<iostream>
#include<fstream>
#include<string>
using namespace std;
const int nubofCourse = 10;//学生最多可以选修的课程
typedef struct StudentMessage *sMessage;//学生结点指针类型
typedef struct Courses *sCourse;//课程结点指针类型
fstream foutint;//文件导入导出
/*课程结构体*/
struct Courses {
	int stdCourstcount;
	string cNo;
	string cName;
	string scTeacher;
	string stdNo[nubofCourse];
	sCourse cNext;
};
/*学生结构体*/
struct StudentMessage {
    string sNo;//学号
	string sClass;
	string sName;
	char  sSex;
	sMessage sNext;
};

typedef sMessage sm;//学生头指针类型
typedef sCourse sc;//课程头指针类型
/*关于我们,关于程序*/
void aboutMe() {  //首页打印设置
	string input;
	cout << "\n\n\t\t\t*****************************\n";
	cout << "\t\t\t      学生信息管理系统\n";
	cout << "\t\t\t*****************************\n\n\n";
	// cout<<"\n\t\t\t    欢迎来到学生信息管理系统\n\n";
	cout << "--------------------------------------------------------------------------------\n";
	cout << "\n\t\t\t拼搏到无能为力,\n";  cout << "\t\t\t\t       坚持到感动自己!\n";
	cout << "\t   开发者:路ren甲\n\n";  cout << "\t   联系方式:QQ:1508287079     or     Mail To:[email protected]\n";
	cout << " \n--------------------------------------------------------------------------------\n";
	//cout<<"\t______________________________________________________________________\n";
	cout << "\t\t版权所有@路ren甲\n\n\n";
	cout << "\t<输入任意字符进入>\n\t";
	cin >> input;  //让用户输入一个字符后再进行下一步
	system("cls");    //清屏
}
//再见页面
void goodbye() {  //首页打印设置
	string input;
	// cout<<"\n\t\t\t    欢迎来到学生信息管理系统\n\n";
	cout << " \n\n\n\n\n\n\n\n--------------------------------------------------------------------------------\n";
	cout << "\n\t\t可能程序还有许多不足,\n";  cout << "\t\t\t 希望大家可以提出或者修改!\n";
  cout << "\t\t\t\t再见,遇见成功的自己!\n";
	cout << " \n--------------------------------------------------------------------------------\n";
	cout << "\t<输入任意字符关闭>\n\t";
	cin >> input;  //让用户输入一个字符后再进行下一步
	exit(1);    //清屏
}
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓课程函数↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓//
sc initC() {

	sCourse chead;
	chead = new Courses;
	chead->cNext = NULL;
	return chead;
}
//打印课程信息
int ptfselect_SCourse(sc head, string sId) {
	int flags = 0;
	if (head->cNext == NULL) { cout << "\n\t\t\t没有选到课喔……………!_!-_-\n"; return 1; }
	cout << "\t\t课程编号" << "\t   课程名称" << "\t   开课老师" << endl;
	//课程信息
	head = head->cNext;
	while (head != NULL) {
		for (int l = 0; l < nubofCourse; l++) {
			if (head->stdNo[l] == sId) {
				flags = 1;
				cout << "\t\t" << head->cNo << "\t\t" << head->cName << "\t\t" << head->scTeacher << "\t\n";
			}
		}
		head = head->cNext;
	}
	if (flags == 0) { cout << "\n\t\t\t没有选到课喔……………!_!-_-\n"; }
	cout << "\t\t----------------------------------------------------\n";
	return 1;
}
int ptfSCourse(sc cHead) {
	if (cHead->cNext == NULL) { cout << "没有课程信息\n"; return 0; }
	//全部学生信息
	cout << "\n\t\t课程编号" << "\t   课程名称" << "\t   开课老师" << endl;

	cHead = cHead->cNext;
	while (cHead != NULL) {
		cout << "\t\t" << cHead->cNo << "\t\t" << cHead->cName << "\t\t" << cHead->scTeacher<< "\t\n";
		cHead = cHead->cNext;
	}
	return 1;
}
void printfCourse(sc head, int i) {
	//一个课程信息
	int j;
	sCourse find;
	j = 0;
	find = head->cNext;
	cout << "\n\t\t课程编号" << "\t\t课程名称" << "\t\t开课老师" << endl;
	while (find != NULL) {
		j++; if (j == i) {
			cout << "\t\t" << find->cNo << "\t\t" << find->cName << "\t\t" << find->scTeacher << "\t\n";
			break;
		}
		find = find->cNext;
	}

}
void pfCourse(sc head) {
	cout << "\n\t\t课程编号" << "\t\t课程名称" << "\t\t开课老师" << endl;
	cout << "\t\t" << head->cNo << "\t\t" << head->cName << "\t\t" << head->scTeacher << "\t\n";
	cout << endl;
}
////查找课程
int locateCourse(sc chead, string numb) {
	int j = 0;
	chead = chead->cNext;
	while (chead != NULL) {
		j++;//统计
		if (numb == chead->cNo) {
			return j;
		}
		chead = chead->cNext;
	}
	return 0;

}
////添加课程
void addCourse(sc scHead) {
	sc cnew;//新课程
	int  g = 0,k=0;
	char flag = 'y';
	while (flag == 'y') {
		cnew = new Courses;
		cnew->stdCourstcount = 0;

		while (g==0) {
			g = 1;
			cout << "输入课程编号(六位数字):";
			cin >> cnew->cNo;
			if (locateCourse(scHead,cnew->cNo) != 0) { cout << "课程编号已经存在,请重新输入" << endl; g = 0; }

		}
		g = 0;
		cout << "输入课程名称:";
		cin >> cnew->cName;
		cout<<"输入教师姓名:";
		cin >> cnew->scTeacher;
		cnew->cNext = scHead->cNext;
		scHead->cNext = cnew;
		cout << "您想继续进行添加吗?输入y继续,输入n退出" << endl;
		cout << "输入你的选择(y/n):";
		cin >> flag;
	}
	//system("cls");
	cout << "已经添加课程信息成功\n" << endl;

}
//修改课程信息
int updatesCourse(sc chead) {
	string fdc;
	int k = 0;

	if (chead->cNext == NULL) { cout << "没有课程数据,请添加课程" << endl; return 0; }
	cout << "输入修改课程编号:";
	cin >> fdc;
	chead = chead->cNext;
	while (chead != NULL) {
		k++;//统计
		if (fdc == chead->cNo) {
			pfCourse(chead);
			cout << "课程名称:";
			cin >> chead->cName;
			cout << "开课老师:";
			cin >> chead->scTeacher;
			cout << "修改课程" << chead->cNo << "信息成功!";
			return k;
		}
		chead = chead->cNext;
	}
	return 0;

}
int deletesCourse(sc cHead) {
	string del;
	char flag;
	int f = 0;
	sCourse deletestd,preform;
	int j = 0;
	if (cHead->cNext == NULL) { cout << "没有课程数据,请添加课程" << endl; return 0; }
	preform = cHead;
	deletestd = cHead->cNext;//从首节点开始扫描
	cout << "输入删除课程编号:";
	cin >> del;//删除课程

	while (deletestd != NULL) {
		f = 0;
		j++;
		if (deletestd->cNo==del) {
			pfCourse(deletestd);
			cout << "是否删除该课程(y/n),输入你的选择:";
			cin >> flag;
			if (flag == 'y') {
				cout << "删除课程" << deletestd->cName << "成功!";
				preform->cNext = deletestd->cNext;
				delete deletestd;
				return j;
			}
			else {
				cout << "你已经取消删除" << deletestd->cNext->cName << endl;
				return 0;
			}
		}
		preform=preform->cNext;
		deletestd = deletestd->cNext;
		f = 1;
	}
	if (f == 1) { cout << "不存在该学生找到了"; }
	return 0;//不存在该学生找到了
}
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓学生函数↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓//
/*初始化*/
sm init() {
	sMessage shead;
	shead = new StudentMessage;
	shead->sNext = NULL;
	return shead;
}
//打印学生信息
void printfSMessge(sm head, sc cHead) {
	sm find2;
	string fc;
	int i = 0;
	if (head == NULL) cout << "没有学生信息";
	find2 = head->sNext;
	//全部学生信息
	head = head->sNext;
	while (head != NULL) {
		cout << "\t\t---------------------第"<<++i<<"位--------------------------\n";
		cout << "\t\t\t\t姓名:" << head->sName << "\t\n";
		if (head->sSex == '1') {
			cout << "\t\t\t\t性别:男" << "\t\n";
		}
		else if (head->sSex == '0') {
			cout << "\t\t\t\t性别:女" << "\t\n";
		}
		cout << "\t\t\t\t学号:" << head->sNo << "\t\n";
		cout << "\t\t\t\t班级:" << head->sClass << "\t\n";

		cout << "\n\t\t\t选修课程:\n";
		if (find2 != NULL) {
			fc =find2->sNo;
			ptfselect_SCourse(cHead, fc);//输出学生选课
		}
		find2 = find2->sNext;
		head = head->sNext;
	}

}
void printfPerson(sm head, int i,sc cHead) {
	//一个学生信息
	int j;
	string fc;
	sMessage find, find2;
	//if(i==0) return head;
	//	if(i<0) return ;//位置非法。无此结节点
	j = 0;
	find = head->sNext;
	find2 = head->sNext;
	while (find != NULL){
		j++; if (j == i) {
			cout << "\t\t----------------------------------------------------\n";
			cout << "\t\t\t\t姓名:" << find->sName << "\t\n";
			if (find->sSex == '1') {
				cout << "\t\t\t\t性别:男" << "\t\n";
			}
			else if (find->sSex == '0') {
				cout << "\t\t\t\t性别:女" << "\t\n";
			}
			cout << "\t\t\t\t学号:" << find->sNo << "\t\n";
			cout << "\t\t\t\t班级:" << find->sClass << "\t\n";

			cout << "\n\t\t\t选修课程:\n";
			while (find2 != NULL) {
				fc = find2->sNo;
				if(ptfselect_SCourse(cHead, fc)==1) break;//输出学生选课
			}
			break;
		}
		find2 = find2->sNext;
		find = find->sNext;
	}

}
void pfPerson(sm head) {
	cout << "\t\t----------------------------------------------------\n";
	cout << "\t\t\t\t姓名:" << head->sName << "\t\n";
	if (head->sSex == '1') {
		cout << "\t\t\t\t性别:男" << "\t\n";
	}
	else if (head->sSex == '0') {
		cout << "\t\t\t\t性别:女" << "\t\n";
	}
	cout << "\t\t\t\t学号:" << head->sNo << "\t\n";
	cout << "\t\t\t\t班级:" << head->sClass << "\t\n";

	cout << "\t\t----------------------------------------------------\n";
}
////查找学生
int locateStdfByNo(sm sHead, string numb) {
	int j = 0;
	if (sHead->sNext == NULL) { cout << "没有学生数据,请添加学生" << endl; return NULL; }
	sHead = sHead->sNext;
	j = 0;
	while (sHead != NULL) {
		j++;//统计
		if (numb==sHead->sNo) {
			return j;
		}
		sHead = sHead->sNext;
	}
	return 0;
}
int locateByName(sm sHead, string sname,sc cHead) {
	int j = 0;
	sm head=sHead;
	if (sHead->sNext == NULL) { cout << "没有学生数据,请添加学生" << endl; return NULL; }
	sHead = sHead->sNext;
	while (sHead != NULL) {
		j++;
		if (sHead->sName == sname) { printfPerson(head, j, cHead);
		}
		sHead = sHead->sNext;
	}
	return 0;
}
//添加学生
void addStudent(sm sHead) {
	sMessage snew;//新学生
	int f = 1,g=0;
	char flag = 'y';
	while (flag == 'y') {
		snew = new StudentMessage;
		while (f == 1) {//判断学号和输入学号
			f = 0;
			cout << "输入学号6位数字:";
			cin >> snew->sNo;
			if (locateStdfByNo(sHead, snew->sNo) != 0) { cout << "学号已经存在,请重新输入"<<endl; f = 1;}//判断学号是否重复

		}
		cout << "输入姓名:";
		cin >> snew->sName;
		f = 1;
	     while(f==1){
			 f = 0;
		     cout << "输入性别选择<男:1><女:0>:";
		     cin >> snew->sSex;
		    if (snew->sSex!='1'&& snew->sSex != '0'&&f==0) { cout << "选择操作不对,请重新输入"<<endl; f = 1; }

		 }
		 f = 1;
		cout << "输入班级:";
		cin >> snew->sClass;
		snew->sNext = sHead->sNext;
		sHead->sNext = snew;
		pfPerson(snew);
		cout << "您想继续进行添加吗?输入y继续,输入n退出" << endl;
		cout << "输入你的选择(y/n):";
		cin >> flag;

	}
	//system("cls");
	cout << "已经添加学生信息成功" << endl;

}
//修改学生信息
int updates(sm sHead) {
	char flagc = 'y';
	string numb;
	int j = 0,f=1;
	if (sHead->sNext == NULL) { cout << "没有学生数据,请添加学生" << endl; return 0; }
	cout << "输入修改学生学号:";
	cin >> numb;
	sHead = sHead->sNext;
	while (sHead != NULL) {
		j++;//统计
		if ( numb== sHead->sNo) {
			pfPerson(sHead);
			cout << "\n输入修改信息\n";
			while (f == 1) {
				f = 0;
				cout << "输入性别选择<男:1><女:0>:";
				cin >> sHead->sSex;
				if (sHead->sSex != '1' && sHead->sSex != '0') { cout << "选择操作不对,请重新输入" << endl; f = 1; }

			}
			cout << "输入姓名:";
			cin >> sHead->sName;
			f = 1;
			cout << "输入班级:";
			cin >> sHead->sClass;
			return j;
		}
		sHead = sHead->sNext;
	}
	return 0;
}
//删除
int deletesMessage(sm sHead) {
	string numb;
	char flag;
	sMessage deletestd, preform;
	int j = 0, i = 0;
	if (sHead->sNext == NULL) { cout << "没有学生数据,请添加学生" << endl; return 0; }
	preform = sHead;
	deletestd = sHead->sNext;//从首节点开始扫描
	cout << "输入删除学生学号:";
	cin >> numb;

	while (deletestd != NULL) {
		j++;
		if (deletestd->sNo==numb) {
			pfPerson(deletestd);
			cout << "是否删除该学生(y/n),输入你的选择:";
			cin >> flag;
			if (flag == 'y') {
				cout << "你已经删除" << deletestd->sName << "成功!";
				preform->sNext = deletestd->sNext;
				delete(deletestd->sNext);
				return j;
			}
			else {
				cout << "你已经取消删除" << deletestd->sNext->sName;
				return j;
			}
		}
		preform = preform->sNext;
		deletestd = deletestd->sNext;
		i = 1;
	}

	if (i == 1) cout << "没有找到该学生!-_-!\n";

	return 0;//不存在该学生找到了
}
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓选择排序↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓//
sMessage getminkey(sm p) {
	sm minp, exchange, perfrom;
	if (p->sNext == NULL) {
		return p;
	}
	minp = p;
	perfrom = p;
	p = p->sNext;
	while (p) {
		if (minp->sNo>p->sNo) {
			exchange = minp;
			minp = p;
			perfrom->sNext = p->sNext;
			minp->sNext = exchange;//minp是较小值的指针
		}
		perfrom = p;
		p = p->sNext;
	}
	return minp;//返回较小值的指针
}
sm selectsort(sm head, sm newHead) {
	sm j, i, temp;
	if (head->sNext == NULL || newHead == NULL) cout << "没有学生数据,请添加学生\n";
	i = head;
	j = newHead;
	i = i->sNext;
	while (i != NULL) {//尾插法
		i = getminkey(i);
		j->sNext = i;
		temp = i->sNext;
		i->sNext = NULL;
		j = i;
		i = temp;
	}
	head->sNext = newHead->sNext;
	return newHead;
}
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓导出程序↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓//
void savePersonFile(sm student, sc course) {
	ofstream *outfile[50], out;
	int j = 0, k = 0;
	//写入方式为追加
	student = student->sNext;
	course = course->cNext;
	while (student != NULL) {
		string str = "Project16";
		//string i;
		//ostringstream change;
		str.append(student->sName);
		//change << j;
		//i = change.str();
		//str.append(i);
		str.append(".txt");
		outfile[j] = new ofstream(str, ios::ate);
		*outfile[j] << "\t\t\t\t学生信息:" << endl;
		*outfile[j] << "\t\t学号:" << student->sNo << endl;
		*outfile[j] << "\t\t姓名:" << student->sName << endl;
		if (student->sSex = '1'){
			*outfile[j] << "\t\t性别:" << "男" << endl;
		}
		else {
			*outfile[j] << "\t\t性别:" << "女" << endl;
		}
		*outfile[j] << "\t\t班级:" << student->sClass << endl;

		*outfile[j] << "\t\t\t\t选修课程:" << endl;
		while (course != NULL) {
			for (int l = 0; l < nubofCourse; l++) {
				if (course->stdNo[l] == student->sNo) {
					k = 1;
					*outfile[j] << "\t\t课程名称:" << course->cName << endl;
					*outfile[j] << "\t\t课程编号:" << course->cNo << endl;
					*outfile[j] << "\t\t开课老师:" << course->scTeacher << endl;
				}
			}
			course = course->cNext;
		}
		if (k == 0) *outfile[j] << "\t\t\t没有选修课程:" << endl;
		student = student->sNext;
		(*outfile[j]).close();
		j++;
	}

}
void saveCourseToLocal(sc head) {
	ofstream outfile;
	outfile.open("course.txt");
	sc p;
	p = head->cNext;
	while (p != NULL) {
		outfile << p->stdCourstcount << " ";
		outfile << p->cNo << " ";
		outfile << p->cName << " ";
		outfile << p->scTeacher << "\n";
		if(p->stdCourstcount>0){
		  for (int i = 0; i < p->stdCourstcount; i++) {
			  outfile << p->stdNo[i] << "\n";
		   }
		}
		p = p->cNext;
	}
}
void readCourseFromLacal(sc head) {
	fstream fin("course.txt");
	if (fin)
	{
		sc p;
		p = head;
		sc q;
		int stdCourstcount;
		string  scTeacher, cNo, cName,std;
		while (fin >>stdCourstcount >> cNo >> cName >> scTeacher)
		{
			q = new Courses;
			if (stdCourstcount > 0) {
				for (int i = 0; i < stdCourstcount; i++) {
					fin >>std;
					q->stdNo[i] = std;
				}
			}
			q->stdCourstcount = stdCourstcount;
			q->cNo = cNo;
			q->cName = cName;
			q->scTeacher = scTeacher;
			q->cNext = p->cNext;
			p->cNext = q;
		}
		fin.close();
	}
	else
	{
		cerr << "打开文件失败!" << endl;
	}

}
void saveStudentToLocal(sm head) {
	ofstream outfile;
	outfile.open("student.txt");
	sm p;
	p = head->sNext;
	while (p != NULL) {
		outfile << p->sNo << " ";
		outfile << p->sName << " ";
		outfile << p->sSex  << " ";
		outfile << p->sClass << "\n";
		p = p->sNext;
	}
	outfile.close();
}
void readStudentFromLacal(sm head) {
	fstream fin("student.txt");
	if (fin)
	{
		sm p;
		p = head;
		sm q;
		int rowNum = 0;
		string sTel;
		char sSex;
		string  sClass,sNo,sName;
		while (fin >> sNo >> sName >> sSex >> sClass)
		{
			q = new StudentMessage;
			q->sNo = sNo;
			q->sName = sName;
			q->sSex = sSex;
			q->sClass = sClass;

			q->sNext = p->sNext;
			p->sNext = q;
		}
		fin.close();
	}
	else
	{
		cerr << "打开文件失败!" << endl;
	}

}
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓学生选课相关函数↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓//
void stdSelectCourse(sc course, string select, string sNo) {
	//select是课程编号,sNo选课学生学号
	int k=0,j = 0;
	int f = locateCourse(course, select);
	course = course->cNext;
	while (course != NULL) {
		j++; if (j == f) {
			for (int i = 0; i < course->stdCourstcount; i++) {
				course->stdNo[course->stdCourstcount] = sNo;
				cout << "你已经选择了"<<course->cName<<"课程" << endl;
				k = 1;
				break;
			}
			if(k!=1){
			course->stdNo[course->stdCourstcount++] = sNo;
			cout << "\n\t\t\t"<<course->stdNo[course->stdCourstcount - 1] << "恭喜你选课选课成功!";
			}
			break;
		}
		course = course->cNext;
	}
}
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓main函数↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓//
void main() {
	int  i;
	char s1,c;
	sm sort, newHead;
    string sname;
	string numb;
	StudentMessage std;
	int flag = 1, cflag = 1;
	sm head = init();
	newHead = init();
	sc chead = initC();
	aboutMe();

	// 导入学生信息
	readStudentFromLacal(head);
	readCourseFromLacal(chead);
	while (flag == 1) {
		cout << "\n\n\t\t\t*****************************\n";

		cout << "\t\t\t   欢迎来到学生信息管理系统\n";
		cout << "\t\t\t*****************************\n";

		cout << " -------------------------------------------------------------------------------\n";
		cout << "\t\t  选择功能:\n\t\t\t\t1.添加学生\n\t\t\t\t2.查找学生\n\t\t\t\t3.修改学生\n" <<
			"\t\t\t\t4.删除学生\n\t\t\t\t5.学生排序\n\t\t\t\t6.课程管理\n\t\t\t\t7.学生选课\n\t\t\t\t8.学生列表\n\t\t\t\t9.导出学生\n\t\t\t\t0.退出学生管理系统";
		cout << " \n\n-------------------------------------------------------------------------------\n";
		cout << "\t\t\t请输入你的选择后按Enter键进入:";
		cin >> s1;
		//	system("cls");
		switch (s1) {

		case '9':
			system("cls");
			savePersonFile(head, chead);
			saveCourseToLocal(chead);
			saveStudentToLocal(head);
			cout << "\n\n\n----------------------------------导出学生信息----------------------------------\n";
			cout << "\n*******************************导出文件成功************************************";
			cout << "\n!!!!!!!!!!!!!!!已经存储Project16!!!!!!!!!!!!!!!!";
			break;
		case '8':
			system("cls");
			printfSMessge(head, chead);
			break;
		case '0':
			system("cls");
			flag = 0;
			break;
		case '1':
			system("cls");
			cout << "\n\n\n-----------------------------------增加学生-------------------------------------\n";
			addStudent(head);
			break;
		case '2':
			system("cls");
			cout << "\n\n\n----------------------------------查找学生信息----------------------------------\n";

			cout << "1.按学号查询\n2.按姓名查询\n请输入你的选择:";
			cin >> s1;
			switch (s1) {
			case '1':
				cout << "输入学生学号(6位数字):";
				cin >> numb;
				i = locateStdfByNo(head, numb);
				if (head->sNext == NULL) { cout << "没有学生数据,请添加学生" << endl; }
				if (0 != i) printfPerson(head, i, chead); else {
					cout << "没有找到\n";
				}
				break;
			case '2':
				cout << "输入学生姓名:";
				cin >> sname;
				if (head->sNext == NULL) { cout << "没有学生数据,请添加学生" << endl; }
				i = locateByName(head,sname,chead);
				if (0 != i) printfPerson(head, i, chead); else {
					cout << "没有找到\n";
				}
				break;
			}
			break;
		case '3':
			system("cls");
			cout << "\n\n\n----------------------------------更新学生信息----------------------------------\n";

			i = updates(head);
			if (0 != i) printfPerson(head, i, chead); else {
				cout << "没有找到该学生!-_-!\n";
			}
			break;
		case '4':system("cls");
			cout << "\n\n\n----------------------------------删除学生-------------------------------------\n";

			i = deletesMessage(head);
			break;
		case '5':
			system("cls");
			cout << "\n\n\n----------------------------------学生排序信息----------------------------------\n";

			sort = selectsort(head, newHead);
			if (sort) printfSMessge(head, chead);

			//printfSMessge(head, chead);
			break;
		case '6':
			system("cls");
			cflag = 1;
			while (cflag == 1){
				cout << "\n\n\n------------------------------课程管理系统-------------------------------------\n";
				cout << "\n\t\t输入你选择的功能:\n\t\t\t\t1.添加课程信息\n\t\t\t\t2.查找课程\n\t\t\t\t3.修改课程信息\n\t\t\t\t4.删除课程\n\t\t\t\t5.显示课程\n\t\t\t\t0.退出图书管理\n";
				cout << "\n------------------------------课程管理系统-------------------------------------\n\n请输入你的选择:";
				cin >> c;
				switch (c)
				{
				case '1':
					system("cls");
					cout << "\n\n\n----------------------------------增加课程-------------------------------------\n";
					addCourse(chead); ptfSCourse(chead);
					break;
				case '2':
					system("cls");
					cout << "\n\n\n----------------------------------查找课程信息----------------------------------\n";

					cout << "输入课程编号:";
					cin >> numb;
					if (chead->cNext == NULL) { cout << "没有课程数据,请添加课程" << endl;}
					else i = locateCourse(chead, numb);
					if (i != 0) printfCourse(chead, i); else {
						cout << "没有找到课程\n";
					}break;
				case '3':
					system("cls");
					cout << "\n\n\n----------------------------------更新课程信息----------------------------------\n";

					i = updatesCourse(chead);
					if (i != 0) printfCourse(chead, i); else {
						cout << "没有找到该课程课程\n";
					}
					break;
				case '4':
					system("cls");
					cout << "\n\n\n----------------------------------删除课程--------------------------------------\n";
					deletesCourse(chead); break;
				case '5':
					system("cls");
					cout << "\n\n\n----------------------------------显示课程--------------------------------------\n";
					ptfSCourse(chead);
					break;
					case '0':
					system("cls");
					cflag = 0;
					break;
					default:
						break;
				}

			}
			break;
		case '7':
			system("cls");
			cout << "\n\n\n-----------------------------------学生选课-------------------------------------\n";

			bool f = true;
			if(ptfSCourse(chead)!=0){
			string stdNo, select;
			while (f) {
				if (head->sNext == NULL) {
					cout << "没有学生信息,选课成功"; f = false;
				}
				cout << "请输入你的(学生)的学号:";
				cin >> stdNo;
				f = false;
				i = locateStdfByNo(head, stdNo);
				if (0 == i) {
					cout << "不存在该学生,请重新输入\n"; f = true;
				}
			}
			f = true;
			while(f){
				f = false;
				cout << "请输入你要选的课程编号:";
				cin >> select;
				if (locateCourse(chead, select) == 0) {
					cout << "不存在该课程,请重新输入\n"; f = true; ptfSCourse(chead);
				}
			}
			stdSelectCourse(chead,select, stdNo);
			}
			break;

		}

		cflag = 1;
	}
	system("cls");
	goodbye();
}

当然自己水平有限,写的不好,还有很多bug没有完善,希望大家见谅,仅仅供大家参考,希望吐槽。

时间: 2024-10-05 04:31:01

学生管理系统c++的相关文章

学生管理系统(jsp+mysql)

1.实验目的 通过使用 Java Web 技术设计一个简单的数据库管理系统,了解前台页面和后 台编辑页面的区别,掌握 Web 服务器与 MySQL 数据库的连接和数据库操作的方 法,掌握使用 JSP 编写后台代码的方法. 2.实验内容和要求 开发一个学生管理系统,完成学生信息的查看.增加.删除和修改等功能. 对于客户端增加和修改信息页面,要使用 javascript 进行必要的数据的非空验证. 自行添加一些 css,使得页面和字体更加美观. 3.实验步骤及实验结果 (1)打开 MySQL,新建一

用链表写的学生管理系统 成绩的录入与查询都已经是实现了

#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct teacher { char name[32]; int math; int english; int data; struct Node *next; }SLIST; int Creat_SList(); int SList_Print(); int SLis

c语言学生管理系统链表(dev vs2012下可以运行)

struct student { char name[10]; char sex[5]; long int num;//学号 int xuhao; int age; float score[3]; float averange; char DJ;//存放等级哦 struct student *next; };//定义结构体变量保存 名字 性别 年龄 成绩] 结构体声明 int n;//存放学生人数 int man;//存放统计的男生数 float JY(float a)//校验成绩使范围0-10

Mysql学生管理系统:表的建立,外键一对多,多对多关系,中间关联表的建立

学生管理系统 管理员注册/登录/注销 注册班级(班级详细信息) 注册学生信息 查看班级信息/查看老师资料 教师注册/注销  查看教师资料  查看学生资料  根据名称/班级/ 查看学生详细信息--支持模糊 注册科目 管理员(admini) ad_id(管理员id)     ad_number(管理员账号) ad_pass(管理员密码)    ad_yn(管理员是否禁用) create table admini( ad_id int PRIMARY KEY AUTO_INCREMENT,-- 主键自

微信南通大学教务学生管理系统_用户体验

刚开始我还没关注南通大学教务学生管理系统的时候都是经常用电脑登陆然后上去查课表或者成绩什么的,但是用电脑也挺不方便的,因为每次都输用户名和密码,挺烦的.后来关注微信之后觉得还挺方便的,(图片是盗用同学的,因为我的手机屏幕没那么大,不能一下子把整张图一次性截下),但是我想说的他的缺点也就是它的一张图片实在太长了,让人看的眼花,一下子不能马上找到自己想查的是什么,而且我们要查的内容都是通过输入字母和数字组成的,如果一下子记不住字母和数字,还要往上翻页去看一眼什么字母或者数字,才能继续输入.(我不知道

精美学生管理系统

半个学期即将完美结束,精美的学生管理系统也终于亮相啦,哈哈! 话不多说,切入正题. 首先,要了解完成学生管理系统的步骤: 总共有几个模块,我就逐一讲解: 一:完成登录页面模块 判断“登录”是否成功的代码: 1 private void btnLogin_Click(object sender, EventArgs e) 2 { 3 string str = DBHelper.str; 4 SqlConnection con = new SqlConnection(str); 5 string s

【php】1、学生管理系统-欢迎界面

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-

简单的学生管理系统

简单的学生管理系统 一,主要功能: 1,添加学生信息: 2,添加的学生信息显示在线型布局中: 3,把学生信息保存在xml文件中: 4,把保存在mxl中的学生信息取出来解析显示在界面: 二,主要知识点: 1,layout_weight的使用: 2,pull解析xml文件,xml序列化: 3,保存数据到sd卡: 4,动态添加控件刷新界面: 三,界面原型如下图: 四,代码展示: 1,界面xml文件,activity_main.xml <LinearLayout xmlns:android="ht

Servlet实例开发---学生管理系统

Servlet总结 本程序采用Servlet开发技术,MVC分层,所有程序在设计时都要接口为操作的标准,主要逻辑操作只有增删改查. 具体实现操作请看源代码. 本程序采用的是MYSQL数据库,需加入相应的jar包 目录结构 首先贴上底层数据层: 连接数据库 package com.student.dbc ; import java.sql.* ; public class DatabaseConnection { private static final String DBDRIVER = "or

函数调用实例:学生管理系统(前面的优化版),可以弹出窗口。

1 package classwork308; 2 /* 3 * 学生管理系统 4 */ 5 import javax.swing.JOptionPane; 6 7 public class Method_StudentManage { 8 9 /*****管理账号*****/ 10 public static String[] manager={"a","b"}; 11 /*****管理密码*****/ 12 public static int [] passwo