欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

职工学历管理系统

程序员文章站 2022-03-09 07:57:06
...

职工学历管理系统

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

typedef struct
{
	char gonghao[20];//工号
	char mingzi[20];//姓名
	char xingbie[10];//性别
	char xueli[20];
	int time[2];//生日
	char zhicheng[20];//职称
	float gongzi;//工资
}ZG;

ZG zg[100];
int N=0;


/*新增*/
void add_new()
{
	system("cls");
	printf("请输入输入职工工号\n");
	scanf("%s",&zg[N].gonghao);
	printf("请输入输入职工姓名\n");
	scanf("%s",&zg[N].mingzi);
	printf("请输入输入职工性别\n");
	scanf("%s",&zg[N].xingbie);
	printf("请输入输入职工学历\n");
	scanf("%s",&zg[N].xueli);
	do
	{
		printf("请输入输入职工生日(年/月)\n");
		scanf("%d/%d",&zg[N].time[0],&zg[N].time[1]);
		if(zg[N].time[0]<0||zg[N].time[0]>2018||zg[N].time[1]<0||zg[N].time[1]>=13)
		{
			printf("请重新按格式输入\n");
			scanf("%d/%d",&zg[N].time[0],&zg[N].time[1]);
		}
		else
		{
			break;
		}

	}while(1);
	
	
	printf("请输入输入职工职称\n");
	scanf("%s",&zg[N].zhicheng);
	printf("请输入输入职工工资\n");
	scanf("%f",&zg[N].gongzi);
	printf("新增职工信息成功!\n");
	N++;
	system("pause");
}


/*主菜单*/
int caidan()
{
	int n;
	system("cls");
	printf("1:输入信息录入\n");
	printf("2:学历信息排序\n");
	printf("3:查询学历\n");
	printf("4:删除职工信息\n");
	printf("5:浏览职工信息\n");
	printf("0:退出\n");
	printf("请选择编号:");
	scanf("%d",&n);
	while(n<0||n>5)
	{
		printf("输入错误,请重新输入!\n");
		scanf("%d",&n);
	}
	return n;
}

void xianshi()
{
	int i;
	system("cls");
	if(0==N)
	{
		printf("无职工信息!\n");
	}
	else
	{
		printf("%-10s%-10s%-10s%-16s%-11s%-16s%-8s\n","工号","姓名","性别","学历","生日","职称","工资");
		for(i=0;i<N;i++)
		{
			printf("%-10s",zg[i].gonghao);
			printf("%-10s%",zg[i].mingzi);
			printf("%-10s%",zg[i].xingbie);
			printf("%-16s%",zg[i].xueli);
			printf("%5d/%-5d",zg[i].time[0],zg[i].time[1]);
			printf("%-16s",zg[i].zhicheng);
			printf("%-8g\n",zg[i].gongzi);
		}
	}
	system("pause");
}


void paixu()
{
	ZG temp;
	int i,j;
		for(i=0;i<N;i++)
		{
			for(j=i+1;j<N;j++)
			{
				if( strcmp(zg[i].xueli,zg[j].xueli)>0 )
				{
					temp=zg[j];
					zg[j]=zg[i];
					zg[i]=temp;
				}
			}
		}
}

void chaxun()
{
	int i;
	char temp[30];
	system("cls");
	printf("请输入要查询的学历:\n");
	scanf("%s",temp);

	printf("%-10s%-10s%-10s%-16s%-11s%-16s%-8s\n","工号","姓名","性别","学历","生日","职称","工资");
	for(i=0;i<N;i++)
	{
		if(!strcmp(zg[i].xueli,temp))
		{
			printf("%-10s%-10s%-10s%-16s%5d//%-5d%-16s%-8g\n",zg[i].gonghao,zg[i].mingzi,zg[i].xueli,zg[i].time[0],zg[i].time[1],zg[i].zhicheng,zg[i].gongzi);
		}
	}
	system("pause");
}

void shanchu()
{
	int i,j;
	char temp[30];
	system("cls");
	printf("请输入要删除的职工号:\n");
	scanf("%s",temp);
	for(i=0;i<N;i++)
	{
		if(!strcmp(zg[i].gonghao,temp))
		{
			for(j=i;j<N;j++)
			{
				zg[j]=zg[j+1];
			}
			break;
		}
	}
	if(i==N)
	{
		printf("无该职工信息!\n");
	}
	else
	{
		printf("删除成功!\n");
		N--;
	}
	system("pause");
}

int main()
{
	int n;
	do
	{
		n=caidan();
		switch(n)
		{
		case 1:
			add_new();
			break;
		case 2:
			paixu();
			xianshi();
			break;
		case 3:
			chaxun();
			break;
		case 4:
			shanchu();
			break;
		case 5:
			xianshi();
			break;
		}
	}while(n!=0);
	return 0;
}
相关标签: 职工 管理系统