当前位置:首页 » 编程语言 » 输入员工号查找员工信息c语言
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

输入员工号查找员工信息c语言

发布时间: 2023-05-28 22:51:22

⑴ 求一道c语言编程题(职工信息管理程序)

//写这个程序花了我2.5小时写代码
//再花了1个小时测试,全部正确了
//所以一定要给我加分哦,要求100分以上,哈哈
//不然下次就没信心帮你写了
//职工管理系统
//职工号,姓名,性别,年龄,学历,工资,住址,电话等
/*
1、录入职工信息,若录入的职工号重复给予提示;
2、浏览职工信息;
3、职工号和职工姓名查询职工信息;
4、按职工号删除职工信息。
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//下面定义职工信息结构
struct WORKER{
int id; //职工号
char name[20]; //姓名
char sex[3]; //性别
int age; //年龄
char e[50]; //学历
int wages; //工资
char adr[255]; //住址
char phone[13]; //电话
};
typedef struct WORKER *PWORKER;

struct LINK{
WORKER w;
LINK *next;
};
typedef struct LINK *PLINK;

//创建职工信息链表
PLINK create()
{
PLINK p=(PLINK)malloc(sizeof(struct LINK));
if(NULL!=p)
{
p->next=NULL;
return p;
}
printf("内存不足!\n");
return NULL;
}

//显示程序界面文字
void message()
{
system("cls");
printf("欢迎进入职工管理系统\n");
printf(" --帮助 请输入:0\n");
printf(" --录入职工信息 请输入:1\n");
printf(" --浏览职工信息 请输入:2\n");
printf(" --按职工号查询 请输入:3\n");
printf(" --按姓名 查询 请输入:4\n");
printf(" --删除职工信息 请输入:5\n");
printf("\n --清屏 请输入:6\n");
printf(" --退出 请输入:-1\n");
}

//录入职工信息
int add(PLINK p)
{
PLINK q=(PLINK)malloc(sizeof(struct LINK));
if(NULL==q)
{
printf("录入失败提示:内存不足!\n");
return -1;
}
printf("请输入职工号(数字):");
scanf("%d",&q->w.id);
PLINK h=p->next;
while(h)
{
if(h->w.id==q->w.id)
{
free(q);
printf("录入失败提示:此职工号已经存在!\n");
return -1;
}
h=h->next;
}
printf("请输入职工姓名(文字):");
scanf("%s",&q->w.name);
printf("请输入职工性别(文字):");
scanf("%s",&q->w.sex);
printf("请输入职工年龄(数字):");
scanf("%d",&q->w.age);
printf("请输入职工学历(文字):");
scanf("%s",&q->w.e);
printf("请输入职工工资(数字):");
scanf("%d",&q->w.wages);
printf("请输入职工住址(文字):");
scanf("%s",&q->w.adr);
printf("请输入职工电话(文字):");
scanf("%s",&q->w.phone);
q->next=p->next;
p->next=q;
printf("录入成功!\n");
return -1;
}

//浏览职工信息
void show(PLINK p)
{
message();
printf("浏览职工信息\n");
printf("职工号\t姓名\t性别\t年龄\t学历\t工资\t住址\t电话\n");
while(NULL!=p->next)
{
printf("%d\t%s\t%s\t%d\t%s\t%d\t%s\t%s\n",
p->next->w.id,p->next->w.name,p->next->w.sex,p->next->w.adr,
p->next->w.e,p->next->w.wages,p->next->w.adr,p->next->w.phone);
p=p->next;
}
printf("显示完毕!\n");
}

//按职工号查询
PLINK findid(PLINK p,int id)
{
message();
printf("按职工号查询\n");
printf("职工号\t姓名\t性别\t年龄\t学历\t工资\t住址\t电话\n");
while(NULL!=p->next)
{
if(p->next->w.id==id)
{
printf("%d\t%s\t%s\t%d\t%s\t%d\t%s\t%s\n",
p->next->w.id,p->next->w.name,p->next->w.sex,p->next->w.adr,
p->next->w.e,p->next->w.wages,p->next->w.adr,p->next->w.phone);
return p;
}
p=p->next;
}
printf("查询结束!\n");
return NULL;
}

//按姓名 查询
PLINK findname(PLINK p,char *name)
{
message();
printf("按姓名 查询\n");
printf("职工号\t姓名\t性别\t年龄\t学历\t工资\t住址\t电话\n");
while(NULL!=p->next)
{
if(0==strcmp(p->next->w.name,name))
{
printf("%d\t%s\t%s\t%d\t%s\t%d\t%s\t%s\n",
p->next->w.id,p->next->w.name,p->next->w.sex,p->next->w.adr,
p->next->w.e,p->next->w.wages,p->next->w.adr,p->next->w.phone);
return p;
}
p=p->next;
}
printf("查询结束!\n");
return NULL;
}

//按职工号删除职工信息
int del(PLINK p,int id)
{
message();
printf("按职工号删除职工信息\n");
while(NULL!=p->next)
{
if(p->next->w.id==id)
{
PLINK q=p->next;
p->next=p->next->next;
free(q);
printf("删除成功!\n");
return 1;
}
p=p->next;
}
printf("没有你输入的职工号!\n");
return -1;
}

//程序结束时释放内存
void release(PLINK p)
{
PLINK q;
while(NULL!=p->next)
{
q=p;
p=p->next;
free(q);
}
free(p);
}

int main()
{
int cmd=0;//命令号
int id;
char name[20];
PLINK pworker;
if(!(pworker=create()))
{
exit(0);//如果创建职工信息链表表头失败则结束程序
}
while(cmd!=-1)
{
switch(cmd)
{
case 0:
message();
break;
case 1:
add(pworker);
break;
case 2:
show(pworker);
break;
case 3:
printf("请输入要查询的职工号:");
scanf("%d",&id);
findid(pworker,id);
break;
case 4:
printf("请输入要查询的职姓名:");
scanf("%s",name);
findname(pworker,name);
break;
case 5:
printf("请输入要删除的职工号:");
scanf("%d",&id);
del(pworker,id);
break;
case 6:
default:
message();
}
printf("请输入操作命令数字:\n");
scanf("%d",&cmd);//接收命令
}
printf("谢谢使用!\n");
release(pworker);
return 0;
}
//程序有详细说明了
//希望你以后好好学。

⑵ 员工信息管理系统,C语言做

以下是我的程序,刚编好的,刚好符合你的要求,看看吧,对你应该有帮助:
呵呵
#include
#include
#include
#include
#define N 100
struct employee
{
int num;
char name[10];
char sex;
int age;
char xueli[30];
int wage;
char addr[30];
long int tel;
}em[100]; /*定义一个结构体*/

void menu();
void input();
void save(int);
void display();
void del();
void add();
void search();
void search_num();
void search_xueli();
void search_tel();
void modify(); /*定义各函数*/

void menu() /*菜单函数*/
{
printf(" ☆☆☆计算机科学与技术学系☆☆☆\n");
printf("\n");
printf(" ∮08802班 关丽霞∮\n");
printf("\n");
printf(" ******************职工信息管理****************\n");
printf(" 1.录入职工信息");
printf(" 2.浏览职工信息\n");
printf(" 3.查询职工信息");
printf(" 4.删除职工信息\n");
printf(" 5.添加职工信息");
printf(" 6.修改职工信息\n");
printf(" 7.退出\n");
printf(" ********************谢谢使用******************\n");
printf("\n");
printf("\n");

}

void main()
{
menu(); /*调用菜单函数*/
int n,flag;
char a;
do
{
printf("请选择你需要操作的步骤(1--7):\n");
scanf("%d",&n);
if(n>=1&&n<=7)
{
flag=1;
break;
}
else
{
flag=0;
printf("您输入有误,请重新选择!");
}
}
while(flag==0);
while(flag==1)
{
switch(n)
{
case 1:printf(" ◆◆◆输入职工信息◆◆◆\n");printf("\n");input();break;
case 2:printf(" ◆◆◆浏览职工信息◆◆◆\n");printf("\n");display();break;
case 3:printf(" ◆◆◆按职工号查询职工信息◆◆◆\n");printf("\n");search();break;
case 4:printf(" ◆◆◆删除职工信息◆◆◆\n");printf("\n");del();break;
case 5:printf(" ◆◆◆添加职工信息◆◆◆\n");printf("\n");add();break;
case 6:printf(" ◆◆◆修改职工信息◆◆◆\n");printf("\n");modify();break;
case 7:exit(0);break;
default :break;
}
getchar();
printf("\n");
printf("是否继续进行(y or n):\n");
scanf("%c",&a);
if(a=='y')
{
flag=1;
system("cls"); /*清屏*/
menu(); /*调用菜单函数*/
printf("请再次选择你需要操作的步骤(1--6):\n");
scanf("%d",&n);
printf("\n");
}

else
exit(0);
}

}

void input() /*录入函数*/
{
int i,m;
printf("请输入需要创建信息的职工人数(1--100):\n");
scanf("%d",&m);
for (i=0;i<m;i++)
{
printf("职工号: ");
srand((int)time(0));
em[i].num=rand()%10000+20000000;
if(em[i].num!=em[i-1].num)
printf("%8d ",em[i].num);
printf("\n");
printf("请输入姓名: ");
scanf("%s",em[i].name);
getchar();
printf("请输入性别(f--女 m--男): ");
scanf("%c",&em[i].sex);
printf("请输入年龄: ");
scanf("%d",&em[i].age);
printf("请输入学历: ");
scanf("%s",em[i].xueli);
printf("请输入工资: ");
scanf("%d",&em[i].wage);
printf("请输入住址: ");
scanf("%s",em[i].addr);
printf("请输入电话: ");
scanf("%d",&em[i].tel);
printf("\n");

}
printf("\n创建完毕!\n");
save(m);
}

void save(int m) /*保存文件函数*/
{
int i;
FILE*fp;
if ((fp=fopen("employee_list","wb"))==NULL) /*创建文件并判断是否能打开*/
{
printf ("cannot open file\n");
exit(0);
}
for (i=0;i<m;i++) /*将内存中职工的信息输出到磁盘文件中去*/
if (fwrite(&em[i],sizeof(struct employee),1,fp)!=1)
printf("file write error\n");
fclose(fp);
}

int load() /*导入函数*/
{
FILE*fp;
int i=0;
if((fp=fopen("employee_list","rb"))==NULL)
{
printf ("cannot open file\n");
exit(0);
}
else
{
do
{
fread(&em[i],sizeof(struct employee),1,fp);
i++;
}
while(feof(fp)==0);
}
fclose(fp);
return(i-1);
}

void display() /*浏览函数*/
{
int i;
int m=load();
printf("\n 职工号\t姓名\t性别\t年龄\t学历\t工资\t住址\t电话 \n");
for(i=0;i<m;i++) /*m为输入部分的职工人数*/
printf("\n %d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);
}

void del() /*删除函数*/
{

int m=load();
int i,j,n,t,flag;
char name[20];
printf("\n 原来的职工信息:\n");
display(); /* 调用浏览函数*/
printf("\n");
printf("请输入要删除的职工的姓名:\n");
scanf("%s",name);
for(flag=1,i=0;flag&&i<m;i++)
{
if(strcmp(em[i].name,name)==0)
{
printf("\n已找到此人,原始记录为:\n");
printf("\n职工号\t姓名\t性别\t年龄\t学历\t工资\t住址\t电话 \n");
printf("\n%d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);
printf("\n确实要删除此人信息请按1,不删除请按0\n");
scanf("%d",&n);
if(n==1) /*如果删除,则其他的信息都往上移一行*/
{
for(j=i;j<m-1;j++)
{
strcpy(em[j].name,em[j+1].name);
em[j].num=em[j+1].num;
em[j].sex=em[j+1].sex;
em[j].age=em[j+1].age;
strcpy(em[j].xueli,em[j+1].xueli);
em[j].wage=em[j+1].wage;
strcpy(em[j].addr,em[j+1].addr);
em[j].tel=em[j+1].tel;
}
flag=0;
}
}
}
if(!flag)
m=m-1;
else
printf("\n对不起,查无此人!\n");
printf("\n 浏览删除后的所有职工信息:\n");
save(m); /*调用保存函数*/
display(); /*调用浏览函数*/
printf("\n继续删除请按1,不再删除请按0\n");
scanf("%d",&t);
switch(t)
{
case 1:del();break;
case 0:break;
default :break;
}
}

void add()/*添加函数*/
{
FILE*fp;
int n;
int count=0;
int i;
int m=load();
printf("\n 原来的职工信息:\n");
display(); /* 调用浏览函数*/
printf("\n");
fp=fopen("emploee_list","a");
printf("请输入想增加的职工数:\n");
scanf("%d",&n);
for (i=m;i<(m+n);i++)
{
printf("\n 请输入新增加职工的信息:\n");
printf("请输入职工号: ");
srand((int)time(0));
em[i].num=rand()%10000+20000000;
if(em[i].num!=em[i-1].num)
printf("%8d ",em[i].num);
printf("\n");
printf("请输入姓名: ");
scanf("%s",em[i].name);
getchar();
printf("请输入性别(f--女 m--男): ");
scanf("%c",&em[i].sex);
printf("请输入年龄: ");
scanf("%d",&em[i].age);
printf("请输入学历: ");
scanf("%s",em[i].xueli);
printf("请输入工资: ");
scanf("%d",&em[i].wage);
printf("请输入住址: ");
scanf("%s",em[i].addr);
printf("请输入电话: ");
scanf("%d",&em[i].tel);
printf("\n");
count=count+1;
printf("已增加的人数:\n");
printf("%d\n",count);
}
printf("\n添加完毕!\n");
m=m+count;
printf("\n浏览增加后的所有职工信息:\n");
printf("\n");
save(m);
display();
fclose(fp);
}

void search()/*查询函数*/
{
int t,flag;
do
{
printf("\n按职工号查询请按1 ; 按学历查询请按2 ; 按电话号码查询请按3,进入主函数按4\n");
scanf("%d",&t);
if(t>=1&&t<=4)
{
flag=1;
break;
}
else
{
flag=0;
printf("您输入有误,请重新选择!");
}
}
while(flag==0);
while(flag==1)
{
switch(t)
{
case 1:printf("按职工号查询\n");search_num();break;
case 2:printf("按学历查询\n");search_xueli();break;
case 3:printf("按电话号码查询\n");search_tel();break;
case 4:main();break;
default:break;
}

}

}

void search_num()
{
int num;
int i,t;
int m=load();
printf("请输入要查找的职工号(20001111---20009999):\n");
scanf("%d",&num);
for(i=0;i<m;i++)
if(num==em[i].num)
{
printf("\n已找到此人,其记录为:\n");
printf("\n职工号\t姓名\t性别\t年龄\t学历\t工资\t住址\t电话 \n");
printf("\n%d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);
break;
}
if(i==m)
printf("\n对不起,查无此人\n");
printf("\n");
printf("返回查询函数请按1,继续查询职工号请按2\n");
scanf("%d",&t);
switch(t)
{
case 1:search();break;
case 2: break;
default:break;
}
}

void search_xueli()
{
char xueli[30];
int i,t;
int m=load();
printf("请输入要查找的学历:\n");
scanf("%s",xueli);
for(i=0;i<m;i++)
if(strcmp(em[i].xueli,xueli)==0)
{
printf("\n已找到,其记录为:\n");
printf("\n职工号\t姓名\t性别\t年龄\t学历\t工资\t住址\t电话 \n");
printf("\n%d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);

}
if(i==m)
printf("\n对不起,查无此人\n");
printf("\n");
printf("返回查询函数请按1,继续查询学历请按2\n");
scanf("%d",&t);
switch(t)
{
case 1:search();break;
case 2:break;
default :break;
}

}

void search_tel()
{
long int tel;
int i, t;
int m=load();
printf("请输入要查找的电话号码:\n");
scanf("%ld",&tel);
for(i=0;i<m;i++)
if(tel==em[i].tel)
{
printf("\n已找到此人,其记录为:\n");
printf("\n职工号\t姓名\t性别\t年龄\t学历\t工资\t住址\t电话 \n");
printf("\n%d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);
break;
}
if(i==m)
printf("\n对不起,查无此人\n");
printf("\n");
printf("返回查询函数请按1,继续查询电话号码请按2\n");
scanf("%d",&t);
switch(t)
{
case 1:search();break;
case 2:break;
default :break;
}

}

void modify() /*修改函数*/
{
int num;
char name[10];
char sex;
int age;
char xueli[30];
int wage;
char addr[30];
long int tel;
int b,c,i,n,t,flag;
int m=load(); /*导入文件内的信息*/
printf("\n 原来的职工信息:\n");
display(); /* 调用浏览函数*/
printf("\n");
printf("请输入要修改的职工的姓名:\n");
scanf("%s",name);
for(flag=1,i=0;flag&&i<m;i++)
{
if(strcmp(em[i].name,name)==0)
{
printf("\n已找到此人,原始记录为:\n");
printf("\n职工号\t姓名\t性别\t年龄\t学历\t工资\t住址\t电话 \n");
printf("\n%d\t%s\t%c\t%d\t%s\t%d\t%s\t%ld\n",em[i].num,em[i].name,em[i].sex,em[i].age,em[i].xueli,em[i].wage,em[i].addr,em[i].tel);
printf("\n确实要修改此人信息请按1 ; 不修改请按0\n");
scanf("%d",&n);
if(n==1)
{
printf("\n需要进行修改的选项\n 1.职工号 2.姓名 3.性别 4.年龄 5.学历 6.工资 7.住址 8.电话\n");
printf("请输入你想修改的那一项序号:\n");
scanf("%d",&c);
if(c>8||c<1)
printf("\n选择错误,请重新选择!\n");
}
flag=0;
}

}
if(flag==1)
printf("\n对不起,查无此人!\n");
do
{
switch(c) /*因为当找到第i个职工时,for语句后i自加了1,所以下面的应该把改后的信息赋值给第i-1个人*/
{
case 1:printf("职工号改为: ");
scanf("%d",&num);
em[i-1].num=num;
break;
case 2:printf("姓名改为: ");
scanf("%s",name);
strcpy(em[i-1].name,name);
break;
case 3:printf("性别改为: ");
getchar();
scanf("%c",&sex);
em[i-1].sex=sex;
break;
case 4:printf("年龄改为: ");
scanf("%d",&age);
em[i-1].age=age;
break;
case 5:printf("学历改为: ");
scanf("%s",xueli);
strcpy(em[i-1].xueli,xueli);
break;
case 6:printf("工资改为: ");
scanf("%d",wage);
break;
case 7:printf("住址改为: ");
scanf("%s",addr);
strcpy(em[i-1].addr,addr);
break;
case 8:printf("电话改为: ");
scanf("%ld",&tel);
em[i-1].tel=tel;
break;
}
printf("\n");
printf("\n是否确定所修改的信息?\n 是 请按1 ; 不,重新修改 请按2: \n");
scanf("%d",&b);

}
while(b==2);
printf("\n浏览修改后的所有职工信息:\n");
printf("\n");
save(m);
display();
printf("\n继续修改请按1,不再修改请按0\n");
scanf("%d",&t);
switch(t)
{
case 1:modify();break;
case 0:break;
default :break;
}

}

⑶ c语言编程题目求教---输入员工姓名工号进行排序和查找

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#defineEMPCNT10

structemployee
{
intid;
charname[16];
};

voidsort(structemployee*e)
{
inti,j;
structemployeetemp;
for(i=0;i<EMPCNT;i++)
{
for(j=i+1;j<EMPCNT;j++)
{
if(e[j].id<e[i].id)
{
/*swap*/
temp=e[i];
e[i]=e[j];
e[j]=temp;
}
}
}
}

intsearch(structemployee*e,intid)
{
intlow,high,mid;
low=0;
high=EMPCNT-1;
while(low<=high)
{
mid=(low+high)/2;
if(id<e[mid].id)
high=mid-1;
elseif(id>e[mid].id)
low=mid+1;
else
returnmid;
}
return-1;
}

voidmain()
{
structemployeee[EMPCNT];
inti,id=0,m=-1;
for(i=0;i<EMPCNT;i++)
{
printf("输入第%d员工的员工号,姓名:",i+1);
scanf("%d%s",&e[i].id,e[i].name);
fflush(stdin);
}
sort(e);
for(i=0;i<EMPCNT;i++)
printf("%d%s ",e[i].id,e[i].name);

printf("要查找的员工号:");
scanf("%d",&id);
fflush(stdin);
m=search(e,id);
if(m<0)
printf("%d未找到 ",id);
else
printf("%d%s ",e[m].id,e[m].name);

getchar();
}

⑷ 用C语言设计职工信息管理系统

#include<iostream>
#include<string>
#include<fstream>
usingnamespacestd;

constn=50;//定义系统可录入的员工最大数值

stringename[n];
longenum[n];
charesex[n];
inteage[n];
charemarriage[n];
intedepart[n];
inteposition[n];
intedegree[50];
inteworktime[n];
floatepay[n];

classemployee
{
public:
stringemployeename;
longemployeenum;
charemployeesex;
intemployeeage;
charemployeemarriage;
intemployeedepart;
intemployeeposition;
intemployeedegree;
intemployeeworktime;
floatemployeepay;

staticlongemployeemaxnum;
staticfloatemployeebasepay;

voidnewinfo();
voidshowinfo();
voidshowall();
voidshowdepart(intdepart);
voidshowdegree(intdegree);
voidshowage(intmin,intmax);
voidshownum(longnumber);
voidrefreshinfo();
voiddeleteinfo();
floatpay(intemployeegrade);
staticintmaxnum();
};

classdboperate
{
public:
stringemployeename;
longemployeenum;
charemployeesex;
intemployeeage;
charemployeemarriage;
intemployeedepart;
intemployeeposition;
intemployeedegree;
intemployeeworktime;
floatemployeepay;

staticlongemployeemaxnum;
staticfloatemployeebasepay;

voidwritein(intiflag);
voidreadout();
voidrefreshmaxnum(intiflag);//i=1or-1or0
};

longemployee::employeemaxnum=1000;
floatemployee::employeebasepay=1500;

intemployee::maxnum()//返回系统已经存储的人数
{
intmn=0;
ifstreammyf;
myf.open("employeemaxnum.txt");
myf>>mn;
cout<<mn<<endl;
myf.close();
returnmn;
}

voidemployee::newinfo()//添加新成员函数
{
cout<<"新员工姓名:";
cin>>employee::employeename;

employee::employeenum=employeemaxnum+employee::maxnum()+1;

cout<<"新员工性别(f为女性,m为男性):";
cin>>employee::employeesex;

cout<<"新员工年龄:";
cin>>employee::employeeage;

cout<<"新员工婚姻状况(y为已婚,n为未婚):";
cin>>employee::employeemarriage;

cout<<"新员工学历,请输入相应学历的序号:"<<endl;
cout<<"[1:初中2:高中3:本科4:硕士5:博士]";
cin>>employee::employeedegree;
while(employee::employeedegree!=1&&employee::employeedegree!=2&&employee::employeedegree!=3&&employee::employeedegree!=4&&employee::employeedegree!=5)
{
cout<<"输入有误,请重新输入:"<<endl;
cout<<"[1:初中2:高中3:本科4:硕士5:博士]";
cin>>employee::employeedegree;
}

cout<<"新员工所在部门,请输入相应部门的序号:"<<endl;
cout<<"[1:董事会2:市场部3:公关部4:客服中心5:信息中心]";
cin>>employee::employeedepart;
while(employee::employeedepart!=1&&employee::employeedepart!=2&&employee::employeedepart!=3&&employee::employeedepart!=4&&employee::employeedepart!=5)
{
cout<<"输入有误,请重新输入:"<<endl;
cout<<"[1:董事会2:市场部3:公关部4:客服中心5:信息中心]";
cin>>employee::employeedepart;
}

cout<<"新员工职位,请输入相应职位的序号:"<<endl;
cout<<"[1:临时职员2:正式职员3:主任4:部门经理5:董事长]";
cin>>employee::employeeposition;
while(employee::employeeposition!=1&&employee::employeeposition!=2&&employee::employeeposition!=3&&employee::employeeposition!=4&&employee::employeeposition!=5)
{
cout<<"输入有误,请重新输入:"<<endl;
cout<<"[1:临时职员2:正式职员3:主任4:部门经理5:董事长]";
cin>>employee::employeeposition;
}

cout<<"新员工的工作时(不需要输入单位):";
cin>>employee::employeeworktime;

employee::employeepay=employee::pay(employee::employeeposition);

dboperatedbo;
dbo.readout();

intmaxnum=employee::maxnum();

enum[maxnum]=employee::employeenum;
ename[maxnum]=employee::employeename;
esex[maxnum]=employee::employeesex;
eage[maxnum]=employee::employeeage;
emarriage[maxnum]=employee::employeemarriage;
edegree[maxnum]=employee::employeedegree;
edepart[maxnum]=employee::employeedepart;
eposition[maxnum]=employee::employeeposition;
eworktime[maxnum]=employee::employeeworktime;
epay[maxnum]=employee::employeepay;

dbo.writein(1);
cout<<"添加新成员成功!"<<endl;

return;
}

voidemployee::showinfo()//程序主体数据输出函数
{

intchoice1,choice2,min,max;
longsearchnum;
employeee;

cout<<"请选择查询方式:"<<endl;
cout<<"******************************************"<<endl;
cout<<"*输出全体职工信息---------------------1"<<endl;
cout<<"*按职工部门输出-----------------------2"<<endl;
cout<<"*按职工学历输出-----------------------3"<<endl;
cout<<"*按职工年龄输出-----------------------4"<<endl;
cout<<"*按职工编号输出-----------------------5"<<endl;
cout<<"******************************************"<<endl;
cin>>choice1;

switch(choice1)
{
case1:showall();break;
case2:cout<<"请输入要查询职工的部门编号:[1:董事会2:市场部3:公关部4:客服中心5:信息中心]";
cin>>choice2;
e.showdepart(choice2);break;
case3:cout<<"请输入要查询职工的学历编号:[1:初中2:高中3:本科4:硕士5:博士]";
cin>>choice2;
e.showdegree(choice2);break;
case4:cout<<"请输入要查询的年龄范围:";
cout<<"最小值:";
cin>>min;
cout<<"最大值:";
cin>>max;
e.showage(min,max);break;
case5:cout<<"请输入要查询的员工号:";
cin>>searchnum;
e.shownum(searchnum);break;

default:cout<<"出错啦!"<<endl;break;

}

}

voidemployee::showall()//全体员工输出函数
{inti;<br>longnumber;<br>for(i=0;i<employee::maxnum();i++)<br>{<br>number=enum[i];<br>shownum(number);<br>}
}

voidemployee::showdepart(intdepart)//按员工所在部门输出函数
{
inti;
switch(depart)
{
case1:cout<<"董事会的成员有:>"<<endl;break;
case2:cout<<"市场部的成员有:>"<<endl;break;
case3:cout<<"公关部的成员有:>"<<endl;break;
case4:cout<<"客服中心成员有:>"<<endl;break;
case5:cout<<"信息中心成员有:>"<<endl;break;
default:cout<<"输入错误!>"<<endl;break;
}
for(i=0;i<employee::maxnum();i++)
{
if(edepart[i]==depart)
{
longnumber=enum[i];
shownum(number);
}elsecontinue;

}
}

voidemployee::showdegree(intdegree)//按员工学历输出函数
{
inti;
switch(degree)
{
case1:cout<<"初中学历的员工有:"<<endl;break;
case2:cout<<"高中学历的员工有:"<<endl;break;
case3:cout<<"本科学历的员工有:"<<endl;break;
case4:cout<<"硕士学位的员工有:"<<endl;break;
case5:cout<<"博士学位的员工有:"<<endl;break;
}
for(i=0;i<employee::maxnum();i++)
{
if(edegree[i]==degree)
{
longnumber=enum[i];
shownum(number);
}elsecontinue;

}
}

voidemployee::showage(intmin,intmax)//按员工年龄段输出函数
{
inti;
for(i=0;i<employee::maxnum();i++)
{
if(eage[i]>=min&&eage[i]<=max)
{
longnumber=enum[i];
shownum(number);
}
elsecontinue;
}
}

voidemployee::shownum(longnumber)//按员工编号输出函数
{
inti;
for(i=0;i<employee::maxnum();i++)
{
if(enum[i]==number)
{
cout<<"**********************************"<<endl;
cout<<"员工编号>"<<enum[i]<<endl;
cout<<"姓名>"<<ename[i]<<endl;
cout<<"性别>";
if(esex[i]=='f')cout<<"女"<<endl;
elseif(esex[i]=='m')cout<<"男"<<endl;
cout<<"年龄>"<<eage[i]<<"岁"<<endl;
cout<<"婚姻情况>";
if(emarriage[i]=='y')cout<<"已婚"<<endl;
elseif(emarriage[i]=='n')cout<<"未婚"<<endl;
cout<<"学历>";
switch(edegree[i])
{
case1:cout<<"初中"<<endl;break;
case2:cout<<"高中"<<endl;break;
case3:cout<<"本科"<<endl;break;
case4:cout<<"硕士"<<endl;break;
case5:cout<<"博士"<<endl;break;
}

cout<<"所在部门>";
switch(edepart[i])
{
case1:cout<<"董事会"<<endl;break;
case2:cout<<"市场部"<<endl;break;
case3:cout<<"公关部"<<endl;break;
case4:cout<<"客服中心"<<endl;break;
case5:cout<<"信息中心"<<endl;break;
}

cout<<"所任职务>";
switch(eposition[i])
{
case1:cout<<"临时成员"<<endl;break;
case2:cout<<"正式员工"<<endl;break;
case3:cout<<"主任"<<endl;break;
case4:cout<<"部门经理"<<endl;break;
case5:cout<<"董事长"<<endl;break;
}

cout<<"工作时长>"<<eworktime[i]<<"小时"<<endl;
cout<<"额定工资>"<<epay[i]<<"元"<<endl;
cout<<"**********************************"<<endl;
}
elsecontinue;
}
}

voidemployee::refreshinfo()//修改员工信息的函数
{
intcnum=1000;
dboperatedbo;
dbo.readout();
voidemployee::shownum(longnumber);

cout<<"请输入您要修改的员工编号:>";
cin>>cnum;
intmn;
mn=employee::maxnum();

for(inti=0;i<mn;i++)//遍历数据文件,查找要修改的员工数据
{
if(enum[i]==cnum)
{
employee::shownum(cnum);

cout<<"请输入该员工的新信息:"<<endl;

cout<<"新员工姓名:";//录入员工的新的数据,员工号保持不变
cin>>employee::employeename;
ename[i]=employee::employeename;

cout<<"新员工性别:[f为女性,m为男性]:";
cin>>employee::employeesex;
esex[i]=employee::employeesex;

cout<<"新员工年龄:";
cin>>employee::employeeage;
eage[i]=employee::employeeage;

cout<<"新员工婚姻状况(y为已婚,n为未婚):";
cin>>employee::employeemarriage;
emarriage[i]=employee::employeemarriage;

cout<<"新员工学历,请输入相应学历的序号:"<<endl;
cout<<"[1:初中2:高中3:本科4:硕士5:博士]";
cin>>employee::employeedegree;
while(employee::employeedegree!=1&&employee::employeedegree!=2&&employee::employeedegree!=3&&employee::employeedegree!=4&&employee::employeedegree!=5)
{
cout<<"输入有误,请重新输入:"<<endl;
cout<<"[1:初中2:高中3:本科4:硕士5:博士]";
cin>>employee::employeedegree;
}
edegree[i]=employee::employeedegree;

cout<<"新员工所在部门,请输入相应部门的序号:"<<endl;
cout<<"[1:董事会2:市场部3:公关部4:客服中心5:信息中心]";
cin>>employee::employeedepart;
while(employee::employeedepart!=1&&employee::employeedepart!=2&&employee::employeedepart!=3&&employee::employeedepart!=4&&employee::employeedepart!=5)
{
cout<<"输入有误,请重新输入:"<<endl;
cout<<"[1:董事会2:市场部3:公关部4:客服中心5:信息中心]";
cin>>employee::employeedepart;
}
edepart[i]=employee::employeedepart;

cout<<"新员工职位,请输入相应职位的序号:"<<endl;
cout<<"[1:临时职员2:正式职员3:主任4:部门经理5:董事长]";
cin>>employee::employeeposition;
while(employee::employeeposition!=1&&employee::employeeposition!=2&&employee::employeeposition!=3&&employee::employeeposition!=4&&employee::employeeposition!=5)
{
cout<<"输入有误,请重新输

⑸ c语言程序设计。

1、学好C语言,你可以很好地应付任何一种编程工具。

2、一定要多上机练习,通过程式了解相关知识。几经反复方得正果。

3、不要把学习C语言当成一种任务,更不要把它看成很难完成的任务。要充满自信,只要是一个智力正常的人都能学好C语言。始终保持游戏的心态,多发现其中的乐趣。

⑹ 用C语言设计并实现一个员工信息管理系统

#include<iostream>
#include<cstring>
usingnamespacestd;

typedefstructwage{
charunit[8];
charname[10];
charsex[4];
charbirthdate[12];
chartitle[20];
doublebasewage;
doublesubsidy;
doubletax;
doubleexpenses;
doubleresialwage;
}WAGE;

voidComputerResialwage(WAGEa[],intn){
for(inti=0;i<n;++i)
a[i].resialwage=a[i].basewage+a[i].subsidy-a[i].tax-a[i].expenses;
}

voidPrintTitle(void){
cout<<"单位姓名性别出生年月职称基本工资津贴个税水电费实发工资 ";
for(inti=0;i<79;++i)cout<<"*";cout<<endl;
}

voidRowShow(WAGEa[],inti){
cout<<a[i].unit<<"";
if(strlen(a[i].name)==4){
a[i].name[6]=a[i].name[4];
a[i].name[5]=a[i].name[3];
a[i].name[4]=a[i].name[2];
a[i].name[2]=a[i].name[3]='';
}
cout<<a[i].name<<""<<a[i].sex<<""<<a[i].birthdate;
if(strlen(a[i].title)==4){
a[i].title[6]=a[i].title[4];
a[i].title[5]=a[i].title[3];
a[i].title[4]=a[i].title[2];
a[i].title[2]=a[i].title[3]='';
}
cout<<""<<a[i].title<<"";
cout.precision(2);
cout.width(8);
cout<<fixed<<a[i].basewage<<"";cout.width(6);
cout<<fixed<<a[i].subsidy<<"";
cout.width(8);
cout<<fixed<<a[i].tax<<"";
cout.width(6);
cout<<fixed<<a[i].expenses<<"";
cout.width(8);
cout<<fixed<<a[i].resialwage<<endl;
}

voidShow(WAGEa[],intn){
for(inti=0;i<n;++i)RowShow(a,i);
}

voidSearch1(WAGEa[],intn){
inti,flag=1;
for(i=0;i<n;++i){
if(strcmp(a[i].unit,"理学院")==0&&a[i].basewage>900.00&&
strcmp(a[i].title,"副教授")==0&&strcmp(a[i].sex,"男")==0){
RowShow(a,i);
flag=0;
}
}
if(flag)cout<<"(没找到符合条件者) ";
}

voidSearch2(WAGEa[],intn){
inti,flag=1;
for(i=0;i<n;++i){
if(strcmp(a[i].unit,"理学院")==0&&a[i].basewage<1200.00&&
strcmp(a[i].title,"教授")==0&&strcmp(a[i].sex,"男")==0){
RowShow(a,i);
flag=0;
}
}
if(flag)cout<<"(没找到符合条件者) ";
}

intmain(){
WAGEa[]={
{"理学院","赵志军","男","1957-06-25","教授",1150,411,176.6,90},
{"商学院","于铭","女","1979-10-21","助教",500,471,208.9,91},
{"工学院","许炎锋","女","1954-03-08","教授",1250,630,306.2,96},
{"理学院","王嘉","女","1971-06-06","讲师",850,475,100.3,89},
{"工学院","李新江","男","1962-10-02","教授",950,399,49.5,87},
{"商学院","郭海英","女","1963-02-07","副教授",950,332,77.6,85},
{"工学院","马淑恩","女","1960-06-09","副教授",900,791,60.5,45},
{"理学院","王金科","男","1956-09-10","教授",1050,480,325.6,93},
{"理学院","李东慧","女","1950-08-07","教授",1350,364,52.3,94},
{"工学院","张宁","女","1980-01-01","助教",500,395,78,89},
{"商学院","王孟","男","1966-09-08","讲师",800,463,220.3,98},
{"工学院","马会爽","女","1970-02-09","讲师",800,368,101.1,69},
{"工学院","史晓赟","女","1952-06-06","教授",1200,539,520.3,50},
{"理学院","刘燕凤","女","1959-08-07","教授",1200,892,180.9,86},
{"工学院","齐飞","男","1961-04-05","副教授",1200,626,245.6,74},
{"商学院","张娟","女","1975-09-25","助教",650,374,625.3,86},
{"理学院","潘成文","男","1965-10-09","讲师",950,402,1050,90},
{"工学院","邢易","女","1981-02-25","助教",600,325,300,90},
{"商学院","谢枭豪","女","1950-11-18","教授",1350,516,200,90},
{"工学院","胡洪静","女","1952-06-24","教授",1350,277,100,86},
{"工学院","李云飞","男","1969-05-04","讲师",960,729,56,89},
{"商学院","张奇","女","1970-05-28","讲师",960,331,69,89},
{"理学院","夏小波","女","1968-08-01","讲师",960,482,89,45},
{"工学院","王玮","女","1972-11-05","讲师",960,340,98,79},
{"理学院","张帝","女","1950-03-26","教授",1300,335,124,90},
{"商学院","孙帅","男","1966-05-24","讲师",900,748,326,79},
{"工学院","卜辉娟","女","1960-05-23","教授",960,481,651,78},
{"工学院","李辉玲","女","1978-09-09","助教",630,379,400,77},
{"理学院","刘亚静","男","1969-08-09","副教授",890,377,23,66},
{"工学院","尹娴","女","1958-06-09","教授",1050,955,59,65},
{"商学院","马春英","男","1964-12-06","讲师",850,387,78,69},
{"工学院","孟梦","女","1965-08-09","副教授",850,753,485.6,93},
{"工学院","梁晓萌","女","1975-06-09","助教",650,551,136.5,99},
{"理学院","张然","女","1973-03-03","讲师",800,761,203.1,100},
{"工学院","彭雁南","男","1978-05-09","助教",650,200,200,90}
};
inti,n=sizeof(a)/sizeof(a[0]);
if(n==0)return1;
ComputerResialwage(a,n);
PrintTitle();
for(i=0;i<n;++i)RowShow(a,i);
for(i=0;i<79;++i)cout<<"*";
cout<<endl;cout<<" 理学院,基本工资高于900元的男副教授有: ";
PrintTitle();
Search1(a,n);
for(i=0;i<79;++i)cout<<"*";
cout<<endl;
cout<<" 理学院,基本工资低于1200元的男教授有: ";
PrintTitle();
Search2(a,n);
for(i=0;i<79;++i)cout<<"*";
cout<<endl<<endl;
return0;
}

⑺ 求一个c语言人事管理系统

不灭王朝

码龄9年

关注
int menu(){
printf("请按提示输入完成操作!\n");
printf("1.查询员工信息\n");
printf("2.统计员工数量\n");
printf("3.录入员工信息\n");
printf("4.删除员工信息\n");
printf("5.按id排序所有员工\n");
printf("6.打印所有员工信息\n");
printf("7.退出系统\n");
return 0;
}

如menu()函数所示,该系统一共有7个功能

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct emp{
int id;
char name[50];
struct emp * next;
// struct emp * prev;
};

struct emp * initList();

struct emp * addListTailNode(struct emp * head);

struct emp * deleteListNode(struct emp * head,int id);

struct emp * searchEmp(struct emp * head,int id);

int printList(struct emp * l);

int printNode(struct emp * p);

struct emp * sortList(struct emp * head);

int getListLen(struct emp * head);

int writeToDisk(struct emp * head);

struct emp * readFromDisk();

int menu();

int usage(struct emp * head);

#include "emp.h"

int main(){
struct emp * head;
head=readFromDisk();
usage(head);
return 0;
}

struct emp * initList(){
struct emp * head;
head=(struct emp *)malloc(sizeof(struct emp));
head->next=NULL;
return head;
}

struct emp * addListTailNode(struct emp * head){
int id;
char name[50];
struct emp * p, * last , * check;
last = head;
while(last->next!=NULL){
last=last->next;
}
printf("依次输入:员工id号,姓名!\n");
scanf("%d%s",&id,&name);
check = head;
while(check!=last){ //遍历
check=check->next;
if(id==check->id){
printf("添加失败!员工id号重复!\n");
return head;
}
}
p=(struct emp *)malloc(sizeof(struct emp));
p->id=id;
strcpy(p->name,name);
//
last->next=p;
last=p;
p->next=NULL;
printf("%s员工信息已添加!\n",p->name);
return head;
}

struct emp * deleteListNode(struct emp * head,int id){
struct emp * p,* q;
p = head->next;
while(p!=NULL){
if(p->next->id==id){
break;
}
p=p->next;
}
if(head->next==NULL){
printf("书籍信息为空!删除失败!\n");
}
else{
q = p->next;
p->next = q->next;
printf("%s书籍信息被删除!\n",q->name);
free(q);
}
return head;
}

struct emp * searchEmp(struct emp * head,int id){//查询,返回节点信息
struct emp * p;
p = head->next;
while(p!=NULL){
if(p->id==id){
break;
}
p=p->next;
}
return p;
}

int printNode(struct emp * p){//打印节点信息
if(p!=NULL){
printf("员工id: %d 员工姓名:%s\n",p->id,p->name);
}
else{
printf("系统内无该员工信息!\n");
}
return 0;
}

int printList(struct emp * head){ //打印整条链表
struct emp * p;
p = head->next;
while(p!=NULL){
printNode(p);
p=p->next;
}
return 0;
}

struct emp * sortList(struct emp * head){//排序
struct emp * p,* q;
int temp_id;
char temp_name[50];
for(p=head->next;p!=NULL;p=p->next){
for(q=p->next;q!=NULL;q=q->next){
if(p->id>q->id){
temp_id = q->id;
q->id = p->id;
p->id = temp_id;
//
strcpy(temp_name,q->name);
strcpy(q->name,p->name);
strcpy(p->name,temp_name);
}
}
}
return head;
}

int getListLen(struct emp * head){
int len=0;
struct emp * p;
p=head->next;
while(p!=NULL){
len++;
p=p->next;
}
return len;
}

int writeToDisk(struct emp * head){
FILE * fp;
struct emp * p;
if((fp = fopen("D:\\emp.hhtx", "w")) == 0){
printf("写入失败……!\n");
return 0;
}
//
p=head->next;
while(p!=NULL){
fwrite(p,sizeof(struct emp),1,fp);
printf("%d %s\n",p->id,p->name);
p=p->next;
}
fclose(fp);
return 0;
}

struct emp * readFromDisk(){
FILE * fp;
struct emp * head,* last,* p,* temp;
head = initList();
if((fp = fopen("D:\\emp.hhtx", "r")) == 0){
printf("加载失败……未找到存档数据!\n\n");
return head;
}
//
last = head;
p=(struct emp *)malloc(sizeof(struct emp));
while(p!=NULL){
p=(struct emp *)malloc(sizeof(struct emp));
fread(p,sizeof(struct emp),1,fp);
printf("读取数据: %d %s\n",p->id,p->name);
//
last->next=p;
last=p;
p=p->next;
}
fclose(fp);
printf("系统数据初始化完成!");
return head;
}

int menu(){
printf("请按提示输入完成操作!\n");
printf("1.查询员工信息\n");
printf("2.统计员工数量\n");
printf("3.录入员工信息\n");
printf("4.删除员工信息\n");
printf("5.按id排序所有员工\n");
printf("6.打印所有员工信息\n");
printf("7.退出系统\n");
return 0;
}

int usage(struct emp * head){
int x,id;
struct emp * p;
menu();
while(1){
printf("请输入序列号:");
scanf("%d",&x);
switch(x){
case 1:
printf("输入所要查询的员工的id号:");
scanf("%d",&id);
p = searchEmp(head,id);
printNode(p);
printf("---------------------------------\n");
break;
case 2:
printf("系统中一共存在%d个员工\n",getListLen(head));
break;
case 3:
head=addListTailNode(head);
printf("---------------------------------\n");
break;
case 4:
printf("输入所要删除的员工的id号:");
scanf("%d",&id);
head=deleteListNode(head,id);
printf("---------------------------------\n");
break;
case 5:
printf("排序开始……\n");
head=sortList(head);
printf("排序已完成!\n");
printf("---------------------------------\n");
break;
case 6:
printList(head);
printf("------

⑻ C语言 职工信息管理系统

#include <stdio.h>
#include <stdlib.h>
#include <windows.h>//system("cls");清屏
#include <string.h>

struct Staff { //员工信息结构体
int Number; //职工号号
char name[20]; //姓名
char sex; // 性别
int age; // 年龄
char ecation[20]; //学历
float wages; //工资
char addr[20]; //住址
char Tel[15]; //电话
};
struct Staff Staffer[100],Staffer1;

//功能函数声明
void menu(); //主菜单
void input(); //输入员工信息
void save(int m); //存储信息
int read(); // 读取信息
void display();//浏览信息
void add() ; //添加
void search(); //查找
void search_name(); //按编号查找
void search_EDU(); //按学历查找
void search_wages(); //按工资查找
void Delete(); //删除操作
void change(); //修改操作
void order(); //排序操作
void order_Num(); //按职工号排序 //浏览信息时按照职工号由小到大顺序排序
void order_name();//按职工姓名排序
void order_age();//按职工年龄排序

//主函数

void main()
{ int n,f;
while(1)
{
do {
menu(); //*调用菜单函数*
printf("请输入你需要操作的序号(1-8): ");
scanf("%d",&n);
if(n>=1&&n<=8) {
f=1;