课程设计下:利用C++实现高校人员信息管理系统

需求分析

该系统所应包含的信息有以下一些:
人员的基本信息:
编号、姓名、年龄、性别、职称等。

实现功能如下:

各种基本数据的录入。
各种基本数据的修改。即:允许对已经录入的数据重新进行编辑、修改。
例如修改信息栏中张三的基本信息
各种基本数据的删除。例如将张三的信息从信息栏中删除
基于各种数据的查询。
基于各种数据的统计。
数据导出:将信息栏中信息导出到指定文件。
数据导入:从指定文件导入信息到信息栏中。

系统环境:

采用C++语言实现,开发环境为Microsoft Visual Studio 2010,可以运行在操作系统windows10。

数据结构设计:

数据结构设计

界面显示:

在这里插入图片描述
在这里插入图片描述

代码如下:

#include "stdafx.h"
#include "teacher.h"
#include "tea.h"
#include "test.h"
#include "po.h"
//教师管理界面
void tea1(tea TEA)
{
	int b,v=Tea3;
	char c;
	do{
		cout<<"教师管理界面"<<endl;
		cout<<"________________________________________________________________________________"<<endl;
		cout<<"1.添加    ";
		cout<<"2.查询    ";
		cout<<"3.显示    ";
		cout<<"4.编辑    ";
		cout<<"5.删除    ";
		cout<<"6.统计    ";
		cout<<"7.保存    ";
		cout<<"8.读取    ";
		cout<<"0.退出    "<<endl;
		cout<<"________________________________________________________________________________"<<endl;
		cout<<"请选择:";cin>>b;
		switch(b)
		{
		case 1:TEA.Add(v);system("pause");break;
		case 2:TEA.Search();system("pause");break;
		case 3:TEA.Show();system("pause");break;
		case 4:TEA.Edit();system("pause");break;
		case 5:TEA.Delete(v);system("pause");break;
		case 6:cout<<"共有教师人数:"<<v<<endl;system("pause");break;
		case 7:TEA.Save();system("pause");break;
		case 8:TEA.Read(v);system("pause");break;
		default:cout<<"\n 错误!"<<endl;system("pause");break;
		case 0:break;
		}
		cin.clear();
		c=getchar();
		system("cls");
	}while(b!=0);
}
//实验员管理界面
void test1(test TES)
{
	int b,v=Testop;
	char c;
	do{
		cout<<"实验员管理界面"<<endl;
		cout<<"________________________________________________________________________________"<<endl;
		cout<<"1.添加    ";
		cout<<"2.查询    ";
		cout<<"3.显示    ";
		cout<<"4.编辑    ";
		cout<<"5.删除    ";
		cout<<"6.统计    ";
		cout<<"7.保存    ";
		cout<<"8.读取    ";
		cout<<"0.退出    "<<endl;
		cout<<"________________________________________________________________________________"<<endl;
		cout<<"请选择:";cin>>b;
		switch(b)
		{
		case 1:TES.Add(v);system("pause");break;
		case 2:TES.Search();system("pause");break;
		case 3:TES.Show();system("pause");break;
		case 4:TES.Edit();system("pause");break;
		case 5:TES.Delete(v);system("pause");break;
		case 6:cout<<"共有实验员人数:"<<v<<endl;system("pause");break;
		case 7:TES.Save();system("pause");break;
		case 8:TES.Read(v);system("pause");break;
		default:cout<<"\n错误!"<<endl;system("pause");break;
		case 0:break;
		}
		cout<<"按回车键返回"<<endl;
		cin.clear();
		c=getchar();
		system("cls");
	}while(b!=0);
}
//行政人员管理界面
void po1(po PO)
{
	int b,v=Policersop;
	char c;
	do{
		cout<<"行政人员管理界面"<<endl;
		cout<<"________________________________________________________________________________"<<endl;
		cout<<"1.添加    ";
		cout<<"2.查询    ";
		cout<<"3.显示    ";
		cout<<"4.编辑    ";
		cout<<"5.删除    ";
		cout<<"6.统计    ";
		cout<<"7.保存    ";
		cout<<"8.读取    ";
		cout<<"0.退出    "<<endl;
		cout<<"________________________________________________________________________________"<<endl;
		cout<<"请选择:";cin>>b;
		switch(b)
		{
		case 1:PO.Add(v);system("pause");break;
		case 2:PO.Search();system("pause");break;
		case 3:PO.Show();system("pause");break;
		case 4:PO.Edit();system("pause");break;
		case 5:PO.Delete(v);system("pause");break;
		case 6:cout<<"共有行政员人数:"<<v<<endl;system("pause");break;
		case 7:PO.Save();system("pause");break;
		case 8:PO.Read(v);system("pause");break;
		default:cout<<"\n 错误!"<<endl;system("pause");break;
		case 0:break;
		}
		cin.clear();
		c=getchar();
		system("cls");
	}while(b!=0);
}
//主函数
int main()
{   tea tea2;
	test tes2;
	po po2;
	int a;
	char c;
	while(1)
	{
		system("cls");
		cout<<endl;
		cout<<"              ****欢迎使用高校人员信息管理系统**** "<<endl;
		cout<<" \n\n\n"<<endl;
		cout<<"                     1.教师管理                    "<<endl;
		cout<<"                     2.实验员管理                  "<<endl;
		cout<<"                     3.行政员管理                  "<<endl;
		cout<<"                     0.退出                        "<<endl;
		cout<<"\n\n\n"<<endl;
		cout<<"请选择:";cin>>a;	
		switch(a)
		{
		case 1:system("cls");tea1(tea2);break;
		case 2:system("cls");test1(tes2);break;
		case 3:system("cls");po1(po2);break;
		case 0:exit(0);break;
		default:cout<<"\n 错误!"<<endl;
		system("pause");
	    c=getchar();
		cin.clear();	 
		break;
		}
	}
	return 0;

}

以下是类:
persion.h

#include<fstream>
#include<iostream>
#include<string>
using namespace std;
static int Tea3;
static int Testop;
static int Policersop;
#define z 666
class person
{
public:
    int num;
	string name;
	string sex;
	int age;
};

tester.h

#include "person.h"
class tester :
	virtual public person
{
public:

	string testroom;
	string post;
	void Input()
	{
		cout<<"请再次输入编号以确定:";cin>>num;
		cout<<"请输入姓名:";cin>>name;
		cout<<"请输入性别:";cin>>sex;
		cout<<"请输入年龄:";cin>>age;
		cout<<"请输入该实验员所在实验室:";cin>>testroom;
		cout<<"请输入该实验员的职务:";cin>>post;
	}
	void Output()
	{
		cout<<"编号: "<<num<<"  "<<"姓名: "<<name<<"  "<<"性别: "<<sex<<"  "<<"年龄: "<<age<<
			"  "<<"所在实验室: "<<testroom<<"  "<<"职务: "<<post<<endl;
	}
 
};


policer.h

#include "person.h"
class policer :
	virtual public person
{
public:
	string polices;
	string post1;
	void Input()
	{
		cout<<"请再次输入编号以确定:";cin>>num;
		cout<<"请输入姓名:";cin>>name;
		cout<<"请输入性别:";cin>>sex;
		cout<<"请输入年龄:";cin>>age;
		cout<<"请输入政治面貌:";cin>>polices;
		cout<<"请输入职称:";cin>>post1;
	}
	void Output()
	{
		cout<<"编号: "<<num<<"  "<<"姓名: "<<name<<"  "<<"性别: "<<sex<<"  "<<"年龄: "<<age<<
			"  "<<"政治面貌: "<<polices<<"  "<<"职称: "<<post1<<endl;
	}

};

teacher.h

#include "person.h"
class teacher :
	virtual public person
{
public:
	string dept;
	string special;
	string title;
	void Input()
	{
		cout<<"请再次输入编号以确定:";cin>>num;
		cout<<"请输入姓名:";cin>>name;
		cout<<"请输入性别:";cin>>sex;
		cout<<"请输入年龄:";cin>>age;
		cout<<"请输入该教师所在系别:";cin>>dept;
		cout<<"请输入该教师专业:";cin>>special;
		cout<<"请输入该教师的职称:";cin>>title;
	}
	void Output()
	{
		cout<<"编号: "<<num<<"  "<<"姓名: "<<name<<"  "<<"性别: "<<sex<<"  "<<"年龄: "<<age<<
			"  "<<"所在系: "<<dept<<"  "<<"专业: "<<special<<"  "<<"职称: "<<title<<endl;
	}
};

方法类:

po.h

#include "policer.h"
class po
{
public:
	policer Po[z];
	int Add(int &w);
	int Search();
	void Show();
	void Edit();
	int Delete(int &w);
	void Save();
	int Read(int &w);

};

po.cpp

#include "StdAfx.h"
#include "po.h"
int po::Add(int &w)
{
	policer t;
	int i,nu;
	if(Policersop==z) 
	{cout<<"人数已满"<<endl;
	return 0;
	}
    cout<<"请输入编号:";cin>>nu;
	for(i=0;i<Policersop;i++)
	{
		if(nu==Po[i].num)
		{cout<<"已有编号,请重新输入"<<endl;
		return 0;
		}
	}
	t.Input();
	Po[Policersop]=t;
	Policersop++;
	w=Policersop;
	cout<<"添加成功!"<<endl;

    return 1;
}
int po::Search()
{
	int j,n;
	cout<<"请输入编号:";cin>>n;
	for(j=0;j<Policersop;j++)
	{
		if(n==Po[j].num) break;
	}
	if(j==Policersop)
		cout<<"没有此人!"<<endl;
	else
		Po[j].Output();

	return 1;
}
void po::Show()
{
	int i;
	if(Policersop==0)
	{cout<<"记录为空!"<<endl; return;}
    for(i=0;i<Policersop;i++)
		Po[i].Output();
}
void po::Edit()
{
	policer t1;
	int j,n;
	cout<<"请输入要编辑的人的编号:";cin>>n;
	for(j=0;j<Policersop;j++)
	{
		if(n==Po[j].num) break;
	}
	if(j==Policersop)
	{cout<<"没有此人!"<<endl;return;};
	cout<<"输入修改后的信息,编号不能改:"<<endl;
	t1.Input();
	Po[j]=t1;
	cout<<"编辑成功!"<<endl;
}
int po::Delete(int &w)
{
	int j,n;
	cout<<"请输入要删除的人的编号:";cin>>n;
	for(j=0;j<Policersop;j++)
	{
		if(n==Po[j].num) break;
	}
	if(j==Policersop)
	{cout<<"没有此人!"<<endl;return 0;};
    for(j;j<Policersop;j++)
	{
		Po[j]=Po[j+1];
	}
	Policersop--;
	w=Policersop;
	cout<<"删除成功!"<<endl;
	return 1;
}
void po::Save()
{
	int i;
    ofstream outfile,outfile1;   
	outfile1.open("Policersop.dat",ios::out);
	outfile1<<Policersop;
	outfile.open("Policers_data.dat",ios::out);   
	   if(!outfile)
	   {cerr<<"没有此文件!"<<endl; return; }
	   for(i=0;i<Policersop;i++)
		    {
		 outfile<<Po[i].num<<endl;
		 outfile<<Po[i].name<<endl;
		 outfile<<Po[i].sex<<endl;
		 outfile<<Po[i].age<<endl;
		 outfile<<Po[i].polices<<endl;
	     outfile<<Po[i].post1<<endl;
	   }
       outfile.close();   
	   cout<<"保存成功!"<<endl;
} 
int po::Read(int &w)
{
	w=0;
	int i;
    ifstream infile,infile1; 
	infile1.open("Policersop.dat",ios::in);
	infile1>>Policersop;
	w=Policersop;
	infile.open("Policers_data.dat",ios::in);   
	   if(!infile)
	   {cerr<<"没有此文件!"<<endl; return 1; }
	   for(i=0;i<Policersop;i++)
		    { infile>>Po[i].num;
	     infile>>Po[i].name;
	     infile>>Po[i].sex;
		 infile>>Po[i].age;
		 infile>>Po[i].polices;
		 infile>>Po[i].post1;}
       infile.close();  
	   cout<<"读取成功!"<<endl;
	   return 0;
}

tea.h

#include "teacher.h"

class tea
{
	public:
	teacher Tea[z];
	int Add(int &w);
	int Search();
	void Show();
	void Edit();
	int Delete(int &w);
	void Save();
	int Read(int &w);
	tea(void);
	~tea(void);
};

tea.cpp


#include "StdAfx.h"
#include "tea.h"
int tea::Add(int &w)
{
	teacher t;
	int i,nu;
	if(Tea3==z) 
	{cout<<"人数已满"<<endl;
	return 0;
	}
    cout<<"请输入编号:";cin>>nu;
	for(i=0;i<Tea3;i++)
	{
		if(nu==Tea[i].num)
		{cout<<"已有编号,请重新输入"<<endl;
		return 0;
		}
	}
	t.Input();Tea[Tea3]=t;Tea3++;
	w=Tea3;
	cout<<"添加成功!"<<endl;
    return 1;
}
int tea::Search()
{
	int j,n;
	cout<<"请输入编号:";cin>>n;
	for(j=0;j<Tea3;j++)
	{
		if(n==Tea[j].num) break;
	}
	if(j==Tea3)
		cout<<"没有此人!"<<endl;
	else
		Tea[j].Output();
	return 1;
}
void tea::Show()
{
	int i;
	if(Tea3==0)
	{cout<<"记录为空!"<<endl; return;}
    for(i=0;i<Tea3;i++)
		Tea[i].Output();
}
void tea::Edit()
{
	teacher t1;
	int j,n;
	cout<<"请输入要编辑的人的编号:";cin>>n;
	for(j=0;j<Tea3;j++)
	{
		if(n==Tea[j].num) break;
	}
	if(j==Tea3)
	{cout<<"没有此人!"<<endl;return;};
	cout<<"输入修改后的信息,编号不能改:"<<endl;
	t1.Input();
	Tea[j]=t1;
	cout<<"编辑成功!"<<endl;
}
int tea::Delete(int &w)
{
	int j,n;
	cout<<"请输入要删除的人的编号:";cin>>n;
	for(j=0;j<Tea3;j++)
	{
		if(n==Tea[j].num) break;
	}
	if(j==Tea3)
	{cout<<"没有此人!"<<endl;return 0;};
    for(j;j<Tea3;j++)
	{
		Tea[j]=Tea[j+1];
	}
	Tea3--;
	w=Tea3;
	cout<<"删除成功!"<<endl;
	return 1;
}
void tea::Save()
{
	int i;
    ofstream outfile,outfile1;   
	outfile1.open("Tea3.dat",ios::out);
	outfile1<<Tea3;
	outfile.open("Tea_data.dat",ios::out);   
	   if(!outfile)
	   {cerr<<"没有此文件!"<<endl; return; }
	   for(i=0;i<Tea3;i++)
		   {
			 outfile<<Tea[i].num<<endl;
	         outfile<<Tea[i].name<<endl;
	 		 outfile<<Tea[i].sex<<endl;
			 outfile<<Tea[i].age<<endl;	 
		     outfile<<Tea[i].dept<<endl;	
		     outfile<<Tea[i].special<<endl;
 			 outfile<<Tea[i].title<<endl;
	   }
       outfile.close();   
	   cout<<"保存成功!"<<endl;
} 
int tea::Read(int &w)
{
	w=0;
	int i;
    ifstream infile,infile1; 
	infile1.open("Tea3.dat",ios::in);
	infile1>>Tea3;
	w=Tea3;
	infile.open("Tea_data.dat",ios::in);   
	   if(!infile)
	   {cerr<<"没有此文件!"<<endl; return 0; }
	   for(i=0;i<Tea3;i++)
		  { infile>>Tea[i].num;
			 infile>>Tea[i].name;
			 infile>>Tea[i].sex;
			 infile>>Tea[i].age;
			 infile>>Tea[i].dept;
			 infile>>Tea[i].special;
			 infile>>Tea[i].title;
	   }
			
       infile.close();  
	   cout<<"读取成功!"<<endl;
	   return 0;
} 

tea::tea(void)
{
}


tea::~tea(void)
{
}


test.h

#include "tester.h"
class test
{
public:
	tester Test[z];
	int Add(int &w);
	int Search();
	void Show();
	void Edit();
	int Delete(int &w);
	void Save();
	int Read(int &w);

};

test.cpp

#include "StdAfx.h"
#include "test.h"
int test::Add(int &w)
{
	tester t;
	int i,nu;
	if(Testop==z) 
	{cout<<"人数已满"<<endl;
	return 0;
	}
    cout<<"请输入编号:";cin>>nu;
	for(i=0;i<Testop;i++)
	{
		if(nu==Test[i].num)
		{cout<<"已有编号,请重新输入"<<endl;
		return 0;
		}
	}
	t.Input();
	Test[Testop]=t;
	Testop++;
	w=Testop;
	cout<<"添加成功!"<<endl;

    return 1;
}
int test::Search()
{
	int j,n;
	cout<<"请输入编号:";cin>>n;
	for(j=0;j<Testop;j++)
	{
		if(n==Test[j].num) break;
	}
	if(j==Testop)
		cout<<"没有此人!"<<endl;
	else
		Test[j].Output();
	return 1;
}
void test::Show()
{
	int i;
	if(Testop==0)
	{cout<<"记录为空!"<<endl; return;}
    for(i=0;i<Testop;i++)
		Test[i].Output();
}
void test::Edit()
{
	tester t1;
	int j,n;
	cout<<"请输入要编辑的人的编号:";cin>>n;
	for(j=0;j<Testop;j++)
	{
		if(n==Test[j].num) break;
	}
	if(j==Testop)
	{cout<<"没有此人!"<<endl;return;};
	cout<<"输入修改后的信息,编号不能改:"<<endl;
	t1.Input();
	Test[j]=t1;
	cout<<"编辑成功!"<<endl;
}
int test::Delete(int &w)
{
	int j,n;
	cout<<"请输入要删除的人的编号:";cin>>n;
	for(j=0;j<Testop;j++)
	{
		if(n==Test[j].num) break;
	}
	if(j==Testop)
	{cout<<"没有此人!"<<endl;return 0;};
    for(j;j<Testop;j++)
	{
		Test[j]=Test[j+1];
	}
	Testop--;
	w=Testop;
	cout<<"删除成功!"<<endl;
	return 1;
}
void test::Save()
{
	int i;
    ofstream outfile,outfile1;   
	outfile1.open("Test.dat",ios::out);
	outfile1<<Testop;
	outfile.open("Test_data.dat",ios::out);   
	   if(!outfile)
	   {cerr<<"没有此文件!"<<endl; return; }
	   for(i=0;i<Testop;i++)
		 		   {
			 outfile<<Test[i].num<<endl;
	         outfile<<Test[i].name<<endl;
	 		 outfile<<Test[i].sex<<endl;
			 outfile<<Test[i].age<<endl;	 
		     outfile<<Test[i].testroom<<endl;	
		     outfile<<Test[i].post<<endl;
	   }
       outfile.close();   
	   cout<<"保存成功!"<<endl;
} 
int test::Read(int &w)
{
	int i;
    ifstream infile,infile1; 
	infile1.open("Test.dat",ios::in);
	infile1>>Testop;
	w=Testop;
	infile.open("Test_data.dat",ios::in);   
	   if(!infile)
	   {cerr<<"没有此文件!"<<endl; return 1; }
	   for(i=0;i<Testop;i++)
	  { infile>>Test[i].num;
			 infile>>Test[i].name;
			 infile>>Test[i].sex;
			 infile>>Test[i].age;
			 infile>>Test[i].testroom;
			 infile>>Test[i].post;
	   }
       infile.close();  
	   cout<<"读取成功!"<<endl;
	   return 0;
}

下载链接

仅供学习参考,文件下载链接C++实现高校人员信息管理系统

  • 10
    点赞
  • 91
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1、问题描述 某高校有四类员工教师、实验员、行政人员教师兼行政人员共有的信息包括编号、姓名、性别、年龄等。其中教师还包含的信息有所在系部、专业、职称实验员还包含的信息由所在实验室、职务行政人员还包含的信息有政治面貌、职称等。 2、功能要求 (1)添加功能程序能够任意添加上述四类人员的记录可提供选择界面供用户选择所要添加的人员类别要求员工的编号要唯一如果添加了重复编号的记录时则提示数据添加重复并取消添加。 (2)查询功能可根据编号、姓名等信息对已添加的记录进行查询如果未找到给出相应的提示信息如果找到则显示相应的记录信息。 (3)显示功能可显示当前系统中所有记录每条记录占据一行。 (4)编辑功能可根据查询结果对相应的记录进行修改修改时注意编号的唯一性。 (5)删除功能主要实现对已添加的人员记录进行删除。如果当前系统中没有相应的人员记录则提示“记录为空”并返回操作否则输入要删除的人员的编号或姓名根据所输入的信息删除该人员记录如果没有找到该人员信息则提示相应的记录不存。 (6)统计功能能根据多种参数进行人员的统计。能统计四类人员数量以及总数,统计男、女员工的数量。 (7)保存功能可将当前系统中各类人员记录存入文件中存入方式任意。 (8)读取功能可将保存在文件中的人员信息读入到当前系统中供用户进行使用。
高校人员信息管理系统是一种用于高校管理人员信息的系统,旨在提高高校人员信息管理效率和准确性。系统通过使用C语言进行编写,以下是关于该系统的源码设计: 1. 头文件包含 #include <stdio.h> #include <stdlib.h> #include <string.h> 2. 定义结构体 typedef struct { char name[50]; // 姓名 int age; // 年龄 char gender[10]; // 性别 char department[50]; // 部门 char position[50]; // 职位 } Employee; 3. 主函数 int main() { Employee employees[100]; // 定义最多100个员工 int numEmployees = 0; // 当前员工数目 while (1) { // 显示主菜单 printf("========= 高校人员信息管理系统 =========\n"); printf("1. 添加员工信息\n"); printf("2. 查找员工信息\n"); printf("3. 修改员工信息\n"); printf("4. 删除员工信息\n"); printf("5. 显示所有员工信息\n"); printf("6. 退出系统\n"); printf("请选择操作:"); int choice; scanf("%d", &choice); switch (choice) { case 1: // 添加员工信息 printf("请输入员工姓名:"); scanf("%s", employees[numEmployees].name); printf("请输入员工年龄:"); scanf("%d", &employees[numEmployees].age); printf("请输入员工性别:"); scanf("%s", employees[numEmployees].gender); printf("请输入员工部门:"); scanf("%s", employees[numEmployees].department); printf("请输入员工职位:"); scanf("%s", employees[numEmployees].position); numEmployees++; break; case 2: // 查找员工信息 // 省略查找员工信息的代码 break; case 3: // 修改员工信息 // 省略修改员工信息的代码 break; case 4: // 删除员工信息 // 省略删除员工信息的代码 break; case 5: // 显示所有员工信息 printf("所有员工信息如下:\n"); for (int i = 0; i < numEmployees; i++) { printf("姓名:%s\t年龄:%d\t性别:%s\t部门:%s\t职位:%s\n", employees[i].name, employees[i].age, employees[i].gender, employees[i].department, employees[i].position); } break; case 6: // 退出系统 printf("谢谢使用,再见!\n"); exit(0); default: printf("无效的选项,请重新选择。\n"); break; } } return 0; } 以上是一个简单的高校人员信息管理系统的C语言源码设计,通过该系统可以实现添加、查找、修改、删除和显示所有员工信息的功能,提高高校人员信息管理的效率和准确性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值