c语言程序设计档案管理,c语言程序设计

《c语言程序设计》由会员分享,可在线阅读,更多相关《c语言程序设计(7页珍藏版)》请在人人文库网上搜索。

1、C语言课程设计专业 学号 姓名1 设计题目 (c 语言 )本设计要求使用头文件和菜单, 并组成一个工程文件, 对职工的档案进行管理并 生成职工的简明信息。3.2 设计要求 设计要求实现如下功能:( 1)建立 wkrs 职工数据结构,结构含有姓名、序号、性别和年龄信息。 ( 2)建立一个结构数组,以便存储 10 个职工信息。( 3)设计一个 readin 函数,以便采用问答式输入 10 个职工的信息。( 4)编写一个 display 函数,要求使用结构指针作为参数,用来输出结构数组 的内容。( 5)建立 wks 职工简明数据结构,结构中只含有姓名和年龄信息。( 6)编制一个 srt 函数,根据 。

2、wks 结构建立的职工情况,把职工姓名和年龄信 息抽出来,另外建一个只含职工姓名和年龄的 wkshort 结构的数组。( 7)编制一个 delwk 函数,可以从简明数据结构中删去指定的职工数据。如果 数组中没有要删去的职工,则输出没有这个职工的信息;如果将内容全部删去, 应该给出内容已空的提示信息。(8)将上述函数编制在一个文件里,共用一个头文件。 (9)用一个简单的菜单提供上述操作。菜单信息为:1、输入数据2、显示原始数据3、制作简明数据4、删除简明数据5、结束退出Please Input 1-5:源程序: #include #include #include struct wks/* 定义。

3、一个结构体数组存放数组 */ char num10;char name10;char sex3;int age;wksfull2;struct wkshort/* 定义简明数据数组 */ char name10;int age;wksshort2;int n=2;void readin()/* 定义输入职工信息函数 */int i=0;for(i=0;inum,p-name,p-sex,p-age); printf(n);void srt()int i;for(i=0;in;+i)strcpy( wksshorti.name, wksfulli.name); /*将原始 name 复制到简明数。

4、据数组 */wksshorti.age=wksfulli.age; printf(%8s%6dn,wksshorti.name,wksshorti.age); void delwk()/* 定义一个从简明数组中删除信息的函数 */ int i,j,flag=0;char delname10;char *c2=name,age;printf(please input the name to delete:); scanf(%s,delname);for(i=0;in;i+) if(strcmp(wksshorti.name,delname)=0) for(j=i;jn-1;j+) strcpy(。

5、wksshortj.name,wksshortj+1.name); wksshortj.age=wksshortj+1.age;n-;flag=1; if(flag=1) if(n=0) printf(workers data empty!n); elseprintf(n%8st%8sn,c0,c1); for(i=0;in;i+) printf(n%8st%4dn,wksshorti.name,wksshorti.age); if(flag=0)printf(do not have the workers daten );int menu()/* 定义菜单函数 */ int c;printf。

6、(n1.please input wokers original datan); printf(2. please display workers original datan); printf(3. please display workers short datan); printf(4. please delete workers short datan); printf(5.Goodbye!n);printf(please input your selection 1-5:); scanf(%d,&c);return c;void main() int d; for(;) d=menu。

7、();switch(d) case 1: readin(); break;case 2: display(wksfull); break;case 3: srt(); break;case 4: delwk(); break;case 5: printf(Goodbye!n);exit(1);default: printf(input error!please input again!n); break;运行结果 1.please input wokers original datan);2. please display workers original datan);3. please d。

8、isplay workers short datan);4. please delete workers short datan);5. Goodbye !please input your selection 1-5:1 please input the 1 worker information: please input the num : 01Input the name : jams please input the sex:man please input the age:20 please input the 2 worker information: please input t。

9、he num : 02Input the name : jak please input the sex:man please input the age:761. please input wokers original data2. please display workers original data3. please display workers short data4. please delete workers short data5.Goodbye !please input your selection 1-5:2 序号 姓名 01 jams man 02 jak man2。

10、076性别年龄1. please input wokers original data2. please display workers original data3. please display workers short data4. please delete workers short data5. Goodbye !please input your selection 1-5:3 jams 20 jak 761. please input wokers original data2. please display workers original data3. please di。

11、splay workers short data4. please delete workers short data5. Goodbye !please input your selection 1-5:4 please input the name to delete : jams name age jak 761. please input wokers original data2. please display workers original data3. please display workers short data4. please delete workers short data5. Goodbye !Press any key to continue。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值