发布时间 : 星期一 文章c++课设工资管理系统更新完毕开始阅读513f9bf0941ea76e58fa04cb
p=PL->next; } }
//查找
void College::Find() //查找 {
double ID; Person *p1;
Person *p2;
cout<<\输入你要查询的编号:\ cin>>ID; p1=PL->next; p2=PL; while(p1) {
if(p1->num==ID) break; //找到
else {
p2=p1; //继续查找 p1=p1->next; } }
if(!p1) {cout<<\找不到你所查询的人!!!\\n请确认你所查询的编号是否出错!!!\\n\
else
{ cout<<\职工信息表 **\\n\
cout<<\编号 姓名 岗位 课时 收入情况(元)\\n\ p1->Output();} }
//查找职工结点(返回1-找到,0-未找到.结点指针由p1返回,p2为前看指针) int College::Cfind(int ID,Person **p1,Person **p2) /////////////////////////////////////////////////////////////////////////////////////////
{
*p1=PL->next; *p2=PL;
29
while(*p1) {
if((*p1)->num==ID) break; //找到 else {
*p2=*p1; //继续查找 *p1=(*p1)->next; }
}
return *p1?1:0; } void
{
cout<<\删除职工 **\\n\
int num;
Person *p1,*p2;
cout<<\编号:\ if(!Cfind(num,&p1,&p2)) {
cout<<\指定的人员没有找到!\\n\ } else {
p2->next=p1->next; //连接 delete p1;
cout<<\正确删除!\\n\ } Save(); }
void College::Modify() ////////////////////////////////////////////////////////////////////////////////////////////////////////修改职工
{
30
College::Delete()
///////////////////////////////////////////////////////////////////////////////////////////////////////////删除职工
cout<<\修改职工 **\\n\
int num; Person *p1,*p2;
cout<<\编号:\ if(!Cfind(num,&p1,&p2)) {
cout<<\指定的人员没有找到!\\n\ } else {
p1->Output(); //输出原来的职工信息(做提示) p1->Input(); //输入新的职工信息(更新) cout<<\修改完成!\\n\ }
Save(); } void
{
cout<<\职工信息表 **\\n\
cout<<\编号 姓名 岗位 课时 收入情况(元)\\n\
Person *p=PL->next; if(!p) {
cout<<\无职工记录!\\n\ return; }
while(p) //遍历链表,输出职工信息 {
p->Output(); p=p->next; } }
31
College::Print()
////////////////////////////////////////////////////////////////////////////////////////////////////////输出职工信息
void College::Save() ////////////////////////////////////////////////////////////////////////////////////////////////////职工信息存盘?
{
ofstream f(\打开文件
//遍历输出至文件 Person *p=PL->next; while(p) {
p->Output(f); p=p->next; }
f.close(); //关闭文件
cout<<\职工信息已经保存在Person.dat.\\n\ } void
{
char buf[81]; //临时空间 int Duty; //人员类型
Person *p2; //新建结点的指针 long t; //读写位置
//清除现有结点(保留头结点) Clear();
//打开文件
ifstream f(\
//建立结点,读数据 Person *p=PL; //尾结点指针 while(1) {
//读取人员类型
32
College::Build()
///////////////////////////////////////////////////////////////////////////////////////////////////////////////职工信息