跪求高手编写一道程序

hkping420 2011-04-10 10:54:24
编写一个程序用于院校的人事管理,要求能够输入、显示各类人员的信息,假设院校中有四类人员:学生、教师、员工和在职进修教师,他们都有姓名、性别、联系电话等共同信息,学生还有年级、专业课程和各课成绩的信息,员工还有所在部门、工资的信息,教师还有所在部门、工资和所授课程的信息,在职进修教师兼有教师和学生两类信息。
...全文
271 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
新铺村长 2011-04-10
  • 打赏
  • 举报
回复
这种小程序还是自己动手吧!
quwei197874 2011-04-10
  • 打赏
  • 举报
回复
作业贴不会有人回吧.
hzhxxx 2011-04-10
  • 打赏
  • 举报
回复


hkping420

(hkping420)

等 级:
结帖率:42.86%



这个?????????????
CrescentS 2011-04-10
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 z121211221 的回复:]
我觉得你用sql写更方便
[/Quote]
.



游牧小小诗人 2011-04-10
  • 打赏
  • 举报
回复
类,或 结构
小Ray 2011-04-10
  • 打赏
  • 举报
回复

呵呵 以前我也是觉得这样的题目难,

但是其实只要自己好好的看一本基础的书就会做了。

所以还是自己动手吧。
zicheng_lin 2011-04-10
  • 打赏
  • 举报
回复
额,随便也写个简单的,楼主可以参考下(就当自己练习了):
这个程序没有写文件

//Person.h
#include<iostream>
#include <string>
#include <vector>
#include <map>
#include <utility>
using namespace std;

#ifndef PERSON_H
#define PERSON_H

class Person
{
public:
Person();
Person(string ,string ,string ,string ,string,string );
static void display() ;//显示所有信息
static void addinfor(const Person&);//添加信息
static void findinfor();//查询信息
virtual ~Person();
private:
string id;
string name;
string age;
string sex;
string address;
string telephone;
static map<string, vector<Person> > infor;
};
#endif


//Person.cpp
#include "Person.h"

map<string, vector<Person> > Person::infor;

Person::Person() {}

Person::Person(string id1,string name1,string age1,string sex1,string address1,string telephone1)
:id(id1),name(name1),age(age1),sex(sex1),address(address1),telephone(telephone1)
{
}

void Person::display()
{
for(map<string,vector<Person> >::iterator map_it = infor.begin();
map_it != infor.end();++map_it)
{
for(vector<Person>::iterator iter = map_it->second.begin();
iter != map_it->second.end();++iter)
{
cout<<"学号:"<<map_it->first<<" ";
cout<<"姓名:"<<iter->name<<" ";
cout<<"年龄:"<<iter->age<<" ";
cout<<"性别:"<<iter->sex<<" ";
cout<<"地址:"<<iter->address<<" ";
cout<<"电话:"<<iter->telephone<<" "<<endl;


}
}
system("pause");
}

void Person::addinfor(const Person& rhs)
{
vector<Person> ivec;
ivec.push_back(rhs);
infor.insert(make_pair(rhs.id,ivec));


}

void Person::findinfor()
{
cout<<"请输入要查询的学生的学号:"<<endl;
string num;
cin>>num;
map<string,vector<Person> >::iterator map_it = infor.find(num);
if(map_it != infor.end())
{
vector<Person>::iterator iter = map_it->second.begin();
cout<<"学号:"<<map_it->first<<" ";
cout<<"姓名:"<<iter->name<<" ";
cout<<"年龄:"<<iter->age<<" ";
cout<<"性别:"<<iter->sex<<" ";
cout<<"地址:"<<iter->address<<" ";
cout<<"电话:"<<iter->telephone<<" "<<endl;
}
else
{
cout<<"您查找的学生不存在!"<<endl;
}
system("pause");
system("cls"); //清屏


}

Person::~Person()
{
}

//Main.cpp
#include <iostream>
#include <cstdlib>
#include "Person.h"
using namespace std;

void addstu();
int main()
{
cout<<"\t\t***********************************************"<<endl;
cout<<"\t\t***********************************************"<<endl;
cout<<"\t\t\t\t"<<"欢迎进入人事管理系统"<<endl;
cout<<"\t\t***********************************************"<<endl;
cout<<"\t\t***********************************************"<<endl;
cout<<"\n";
cout<<"\n";
cout<<"请选择你要进行的操作......"<<endl;
while(1)
{
cout<<"1:添加学生信息"<<"\t\t\t"<<"2:按学号查询信息"<<endl;
cout<<"\n";
cout<<"3:查看所有学生信息"<<"\t\t\t"<<"4:退出"<<endl;
cout<<"\n";
cout<<"请输入:";
int num;
cin>>num;
switch(num)
{
case 1:
system("cls"); //清屏
addstu();
break;
case 2:
system("cls"); //清屏
Person::findinfor();
break;
case 3:
system("cls"); //清屏
Person::display();
break;
case 4:
exit(0);
break;

}
}

system("pause");
return 0;

}
void addstu()
{
cout<<"学号:";
string id;
try
{
cin>>id;
}
catch(...)
{
cerr<<"对不起你输入的学号超出范围"<<endl;
cin.clear();
}
cout<<"姓名:";
string name;
cin>>name;
cout<<"年龄:";
string age;
cin>>age;
cout<<"性别:";
string sex;
cin>>sex;
cout<<"地址:";
string address;
cin>>address;
cout<<"电话: ";
string telephone;
cin>>telephone;

Person stu1(id,name,age,sex,address,telephone);
Person::addinfor(stu1);
system("cls");
cout<<"一条信息已经添加完毕,请选择接下来的操作:"<<endl;
//continue;
}



有不尽如人意的地方,也请论坛的大牛们指出来哈!~
reactionaries 2011-04-10
  • 打赏
  • 举报
回复
我是来帮忙顶贴的
loving_hoping 2011-04-10
  • 打赏
  • 举报
回复
不想自己做,去猪八戒吧,100块能买个差不多的!
zhangyuehua123 2011-04-10
  • 打赏
  • 举报
回复
我也还在学习
z121211221 2011-04-10
  • 打赏
  • 举报
回复

我觉得你用sql写更方便
pathuang68 2011-04-10
  • 打赏
  • 举报
回复
版规规定,不允许帮别人做作业。
zx361939439 2011-04-10
  • 打赏
  • 举报
回复
很简单啊,干嘛不自己写
Freedom 2011-04-10
  • 打赏
  • 举报
回复
作业贴啊 还是自己动手吧

64,648

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧