//程序主函数头文件
#include<iostream.h>
#include<fstream.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
//定义职员类
class stu
{
public:
stu()
{
}
stu(char n[20],double muc,double number,int a,char s[10],char b[20])
{
strcpy(name,n);
much=muc;
num=number;
age=a;
strcpy(sex,s);
strcpy(bumen,b);
}
double getsum()
{
sum=much;
return sum;
}
private:
char name[20];
double much,sum,num;
int age;
char sex[10],bumen[20];
friend void main();
};
//系统功能主界面显示及功能选择
cout << "职工工作量统计系统" << endl;
cout << "操作: " << endl;
cout << " 1.增加职工人员" << endl;
cout << " 2.删除职工人员" << endl;
cout << " 3.修改职工信息" << endl;
cout << "查询: " << endl;
cout << " 4.按工作量查询职工信息" << endl;
cout << " 5.按姓名查询职工信息" << endl;
cout << " 6.输出所有职工个人信息" << endl;
cout << "生产量排名名次" << endl;
cout << " 7.按职工工作量查询职工排名" << endl;
cout << " 8.退出系统" << endl;
cout << "请输入对应数字完成操作:";
stu* s[100];
file[j] = new ofstream("d:\\stuff.doc", ios::ate);
*file[j] << "姓名" << name << "工作量" << much << "职工号" << num << "性别" << sex << "年龄" << age << "部门" << bumen << endl;
j++;
char p;
char w;
int i = 0, j = 0;
bool flag2 = 0;
do
{
cin >> p;
if ((p >= '1' && p <= '8'))
flag2 = 1;
else
cout << "指令错误,请重新输入:" << endl;
} while (flag2 == 0);
//职工工作量统计系统添加员工信息功能实现
char name[20];
double much, num;
int age;
char sex[10], char bumen[20], char c;
do
{
cout << "请输入您要增加的职工的姓名:" << endl;
cin >> name;
cout << "请输入职工号:" << endl;
cin >> num;
for (int j = 0; j < i; j++)
{
if (s[j]->num == num)
{
cout << "此员工号已存在,请重新输入";
cin >> num;
}
}
cout << "请输入职工工作量:" << endl;
cin>>much;
cout<<"请输入员工年龄:"<<endl;
cin >> age;
if (age <= 18 || age >= 65)
{
cout << "请输入正确的年龄:" << endl;
cin >> age;
}
cout << "请输入员工性别:" << endl;
cin >> sex;
cout << "请输入员工部门:" << endl;
cin >> bumen;
s[i] = new stu(name, much, num, age, sex, bumen);
i++;
cout << "数据录入成功,想继续录入吗(y/n)" << endl;
cin >> c;
if (c != 'y' && c != 'n')
{
cout << "指令错误!请重新输入" << endl;
cin >> c;
}
} while (c == 'y');
//删除员工信息功能实现
char name[20]; bool flag3 = 0; char c;
do {
cout << "请输入您要删除的职工姓名:" << endl;
cin >> name;
for (int h = 0; h < i; h++)
{
if (strcmp(name, s[h]->name) == 0)
{
flag3 = 1;
i--;
do {
s[h] = s[h + 1];
h++;
} while (h <= i);
}
}
if (flag3 == 0)
{
cout << "要求删除的对象不存在!请检查输入的正确性!";
cout << "要继续删除吗?(y/n)" << endl;
cin >> c;
if (c != 'y' && c != 'n')
{
cout << "指令错误,请重新输入!" << endl;
cin >> c;
}
}
} while (c == 'y');
cout << "删除成功!" << endl;
//修改员工信息功能实现
char name[20]; double mat; flag2 == 0;
char c;
do
{
cout << "请输入您要修改的职工的姓名:" << endl;
cin >> name;
for (int h = 0; h < i; h++)
{
if (strcmp(name, s[h]->name) == 0)
{
flag2 = 1;
cout << "请输入新完成的工作量:" << endl;
cin >> mat;
s[h]->much += mat;
cout << "数据添加成功!";
}
}
if (flag2 == 0)
{
cout << "你要修改的职工本来就不存在!请检查重新输入!" << endl;
}
cout << "想要继续修改吗(y/n)" << endl;
cin >> c;
if (c != 'y' && c != 'n')
{
cout << "指令错误!请重新输入!" << endl;
cin >> c;
}
} while (c == 'y');
//查询员工信息功能实现
char n[20]; int j = 0; char c;
do
{
int flag = 0;
cout << "请输入你要查询的职工姓名:" << endl;
cin >> n;
for (int j = 0; j < i; j++)
{
if (strcmp(n, (*s[j].name) == 0)
{
flag = 1;
cout << "您要查询的职工是:" << endl << (*s[j].name << endl << "工作量:"
<< '' << s[j]->getsum() << '' << "职工号:" << '' << s[j]->num << '' << "年龄:"
<< '' << s[j] - age << '' << "性别:" << '' << s[j]->sex << '' << "部门:"
<< '' << s[j]->bumen << '' << endl;
}
}
if (flag == 0)
cout << "对不起!您要查询的职工不存在!" << endl;
cout << "您要继续查询吗?(y/n)" << endl;
cin >> c;
if (c != 'y' && c != 'n')
{
cout << "指令错误!请重新输入!" << endl;
}
} while (c == 'y');
//显示所有员工信息功能实现
cout << "本系统所有职工个人信息数据如下:" << endl;
if (i == 0)
cout << "管理系统中数据为空!" << endl;
for (int k = 0; k < i; k++)
{
cout << "姓名:" << '' << s[k]->name << '' << "工作量:" << ''s[k]->getsum() << ''
<< "职工号:" << '' << s[k]->num << '' << "年龄:" << '' << s[k]->age << ''
<< "性别:" << '' << s[k]->sex << '' << "部门:" << '' << s[k]->bumen << '' << endl;
}
你要完善啥?
缺 using namespace std;