- 1、本文档共4页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
C 课程设计_4
class Employee
{
public:
struct employee
{
string name;
int num;
double salary;
}worker[100];
int number;
int num();
void add();
void addin();
void dele();
};
void Employee::add()
{
ofstream fout(“employee.txt”);
int i;
int k;
k=num();
for(i=1;i=k;i++)
{
cout”Enter the information of Employee”i”Name:”;
cinworker[i].name;
cout”ID:”;
cinworker[i].num;
cout”Salary:”;
cinworker[i].salary;
}
for(i=0;ik;i++)
{
fout.write((char*)(worker[i]),sizeof(worker[i]));
}
fout.close();
cout”Enter successfully”endl;
}
int Employee::num()
{
cout”Input number of employees:”;
cinnumber;
return number;
}
int Employee::addin()
{
int m=1,n,k;
while(m!=0)
{
cout”Enter info of the added Employee: ”endl;
n=++number;
cout”Enter name of Employee ”n”:”endl;
cinworker[n].name;
cout”Enter ID of Employee ”n”:”endl;
cinworker[n].num;
cout”Enter salary of Employee ”n”:”endl;
cinworker[n].salary;
cout”Continue to add?(yes 1;no 0)”endl;
cinm;
}
ofstream fout(“employee.txt”);
if(!fout)
{
cerr”Open error!”endl;
exit(1);
}
for (k=1;k=number;k++)
{
fout”Name:”worker[k].nameendl;
fout”ID:”worker[k].numendl;
fout”Salary:”worker[k].salaryendl;
}
cout”Add successfully!”;
}
int Employee::dele()
{
int m=1,n,p;
char q;
while(m!=0)
{
cout”Input ID to be deleted:”endl;
cinp;
for(n=0;n=number;n++)
{
if(worker[n].num==p)
{cout”Delete really?(yes ‘Y ’;no ‘N’)”endl;
cinq;
if(q=’Y’)
for(;n=number;n++)worker[n]=worker[n+1];
number--;
}
else break;
}
}
cout”Delete successfully!”endl;
cout”Continue to delete?(yes 1;no 0)”endl;
cinm;
ofstream fout(“employee.txt”);
if(!fout)
{
cerr”Open error!”endl;
exit(1);
}
for (n=1;n=number;n++)
{
cout”Name:”worker[n].nameendl;
cout”ID:”worker[n].numendl;
cout”Salary:”worker[n].salaryendl;
}
}
void login()
{
int choice=0;
Employee e2;
while(choice!=6)
{
cout”Input number to choose function”endl;
cinchoice;
switch(choice)
{
case 1: e2.add();break;
case 2: e2.addin();break;
case 3: e
您可能关注的文档
- 2016年临沂市初中学业水平考试一分一段表共3页(参加中考93400多人,普通高中计划56490人).doc
- VFP第七章(面向对象程序设计).ppt
- VHDL 第一章-概述.ppt
- Visual+C+++中fatal+error+C1083解决办法.doc
- VLAN网络配置.doc
- W3C标准中对css3transition这是样描述.doc
- 贝加莱Automation Studio3.0.80使用新功能.doc
- WEB2.0新网页标准.ppt
- Win7 Access violation at address故障解决方法.doc
- win10驱动出现异常解决办法.doc
- 职业技术学院2024级工业机器人技术(安装与维护)专业人才培养方案.docx
- 职业技术学院2024级应用化工技术专业人才培养方案.pdf
- 职业技术学院2024级软件技术(前端开发)专业人才培养方案.pdf
- 职业技术学院2024软件技术专业人才培养方案.docx
- 职业技术学院2024级信息安全技术应用(安全运维)专业人才培养方案.docx
- 职业技术学院2024级新能源汽车检测与维修技术(车辆鉴定与评估)专业人才培养方案.pdf
- 职业技术学院2024级石油炼制技术专业人才培养方案.pdf
- 职业技术学院2024级环境监测技术专业人才培养方案.docx
- 职业技术学院2024级汽车制造与试验技术专业人才培养方案.pdf
- 职业技术学院2024级信息安全技术应用专业人才培养方案.pdf
文档评论(0)