| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 822 人关注过本帖
标题:[原创]不求加分只求共大家参考!
只看楼主 加入收藏
303770957
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:6
帖 子:838
专家分:2125
注 册:2005-9-10
收藏
 问题点数:0 回复次数:7 
[原创]不求加分只求共大家参考!
企业单位职工工资管理程序 :
程序清单:
#include "stdlib.h"
#include "string.h"
#include "stdio.h"
#define NULL 0
#define LEN sizeof(struct person)
struct person
{ char name[6];
long int id;
int money;
int total;
int handout;
int kouchu;
struct person *next;
};
int n;
char ch[6];
struct person *creat()
{int i;
struct person *head,*p1,*p2;n=0;
p1=p2=(struct person *)malloc(LEN);
printf("请输入人员档案:(输入!结束)\n");
printf("姓名:");
scanf("%s",ch);
head=NULL;
while (strcmp(ch,"!")!=0)
{p1=(struct person *)malloc(LEN);
strcpy(p1->name,ch);
printf("职工号:");
scanf("%ld",&p1->id);
printf("工资:");
scanf("%d",&p1->money);
printf("扣除:");
scanf("%d",&p1->kouchu);
if(n==0) head=p1;
else p2->next=p1;
p2=p1;n++;
printf("姓名:");
scanf("%s",ch);
}
p2->next=NULL;
return (head);
}
void output(struct person *head)
{struct person *p;
int i=0;
printf("*---------------------------------------------------------*\n");
printf("|序号 姓 名 职工号 工资 扣除 总计 实发 | \n");
printf("*---------------------------------------------------------*\n");
p=head;
if(head!=NULL)
do{i++;
printf("| %-d\t %s\t %ld\t %4d\t %d\t %4d\t %4d |\n",i,p->name,p->id,p->money,p->kouchu,(p->money-p->kouchu),(p->money-p->kouchu));
printf("*---------------------------------------------------------*\n");
p=p->next;
}while(p!=NULL);
}
count(struct person *head)
{if(head==NULL)return(0);
else return(1+count(head->next));
}
struct person *insert(struct person *head)
{struct person *p1,*p2,*p3;
printf("请输入新职工的档案情况!\n");
p1=(struct person *)malloc(LEN);
printf("姓名:");
scanf("%s",p1->name);
printf("职工号:");
scanf("%ld",&p1->id);
printf("工资:");
scanf("%d",&p1->money);
printf("扣除:");
scanf("%d",&p1->kouchu);
p2=head;
if(head==NULL)
{head=p1;p1->next=NULL;}
else {while((p1->id>p2->id)&&(p2->next!=NULL))
{p3=p2;
p2=p2->next;}
if(p1->id<=p2->id)
{if(head==p2){p1->next=head;head=p1;}
else {p3->next=p1;p1->next=p2;}
}
else{p2->next=p1;p1->next=NULL;}
}
n++;return(head);
}
struct person *delete (struct person *head,long int num)
{struct person *p1,*p2;
printf("要删除的职工号为:%ld\n",num);
if(head==NULL){printf("这是一个空表,没有可删除的职工号!\n");return(head);}
else{p1=head;
while(num!=p1->id&&p1->next!=NULL)
{p2=p1;p1=p1->next;}
if(num==p1->id)
{if(p1==head) head=p1->next;
else p2->next=p1->next;
printf("删除号为%ld的职工\n",num);
n--;}
else printf("没找到号为%d的职工\n",num);
return(head);
}
}
main()
{struct person *head,pers;
long i;
int k;
printf("企业单位职工工资管理程序\n");
do{printf(" ->主菜单<-\n");
printf("************************\n");
printf("|1.建立全体职工的档案 |\n");
printf("|2.输出全体职工的档案 |\n");
printf("|3.统计全体职工的人数 |\n");
printf("|4.添加职工档案 |\n");
printf("|5.删除职工档案 |\n");
printf("|6.退出本程序 |\n");
printf("************************\n");
printf("请输入选择号(1--6):");
scanf("%d",&k);
switch(k)
{ case 1:head=creat();break;
case 2:printf("本单位职工的人数为:%d人\n",count(head));output(head);break;
case 3:printf("本单位职工的人数为:%d人\n",count(head)); break;
case 4:head=insert(head);printf("\n调整后本单位的职工人数为:%d人\n",count(head));output(head); break;
case 5:printf("请输入要删除的职工号!\n");scanf("%ld",&i);head=delete(head,i);output(head); break;
default:break;
}
}while(k!=6);
}
搜索更多相关主题的帖子: 工资 struct person include 
2005-12-12 03:21
bjdcbltx
Rank: 1
等 级:新手上路
帖 子:167
专家分:0
注 册:2005-12-4
收藏
得分:0 
加分!!!

感谢有大家的陪伴!!! E-mail:bjdcbltx@
2005-12-12 09:05
lihuiyi
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2005-12-14
收藏
得分:0 
2005-12-14 07:23
wenyong
Rank: 1
等 级:新手上路
帖 子:251
专家分:0
注 册:2005-8-9
收藏
得分:0 
格式不错

2005-12-14 08:58
spp509
Rank: 1
等 级:新手上路
威 望:1
帖 子:98
专家分:0
注 册:2005-11-23
收藏
得分:0 

顶你


一听就懂,一看就会,一做就错……
2005-12-18 22:38
等待
Rank: 1
等 级:新手上路
帖 子:173
专家分:0
注 册:2005-12-1
收藏
得分:0 

2005-12-18 23:12
蓝可儿
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2005-12-1
收藏
得分:0 
帮我编个程序吧
用c 语言编图书管理系统简单一点的
行吗?
谢谢了

2005-12-19 11:10
ghy2001
Rank: 1
等 级:新手上路
威 望:1
帖 子:87
专家分:0
注 册:2005-10-30
收藏
得分:0 
有颜色??

2005-12-19 11:27
快速回复:[原创]不求加分只求共大家参考!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016244 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved