网站大量收购独家精品文档,联系QQ:2885784924

C 课程设计_4.doc

  1. 1、本文档共4页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 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

文档评论(0)

xcs88858 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

版权声明书
用户编号:8130065136000003

1亿VIP精品文档

相关文档