软件测试工程师管理系统代码

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include
#include
#include
#include

enum Sex{male,famale}; //性别分类,默认0为男,1为女
enum Education{high,bachelor,master,docter,other}; //学历分类,默认0开始
double Salary={0.0}; //工程师薪水
unsigned int EngineerMonthWorkDays={0}; //工程师工作天数
int n=0; //计数
int EngineerMonthBenefit; //月效益
int EngineerMonthInsurance; //月保险金
struct DateStruct //日期结构,用于存储工程师的出生生日
{
int year;
int month;
int day;
};
struct EngineerStruct //声明存储工程师信息的结构体
{
unsigned int EngineerNo; //工程师编号
char EngineerName[20]; //工程师姓名
unsigned int EngineerSex; //工程师性别
struct DateStruct EngineerBirth; //工程师生日
char EngineerHometown[10]; //工程师籍贯
unsigned int EngineerEducation; //工程师学历
char EngineerAddress[30]; //工程师地址
char EngineerPhone[15]; //工程师电话
unsigned int EngineerWorkYears; //工程师工龄
float EngineerBaseSalary; //工程师基本薪水
struct EngineerStruct *next;
};

void menu() //显示菜单
{
printf("-------------------------------------------------------\n");
printf(": 软件测试工程师管理系统 :\n");
printf("-------------------------------------------------------\n");
printf("\n");
printf("1.输入软件测试工程师资料\n");
printf("2.删除指定测试工程师资料\n");
printf("3.查询软件测试工程师资料\n");
printf("4.修改软件测试工程师资料\n");
printf("5.计算测试工程师的月薪水\n");
printf("6.保存新添加的工程师资料\n");
printf("7.对测试工程师信息排序!\<1编号升序2姓名升序3工龄降序\>\n");
printf("8.输出所有测试工程师信息\n");
printf("9.清空所有测试工程师数据\n");
printf("10.打印软件测试工程师数据报表\n");
printf("11.从文件重新导入测试工程师数据\n");
printf("0.结束\<编辑工程师信息后提示保存\>\n");
printf("\n");
printf("请输入您的选择: ");
}

int Find(struct EngineerStruct *head,unsigned No) //判断该编号是否存在
{
struct EngineerStruct *p1,*p2;
if(head == NULL)
{
return 0;
}
p1 = head;
while (p1->EngineerNo != No && p1->next !=NULL)
{
p2 = p1;
p1 = p1->next;
}

if(No == p1->EngineerNo)
{
return 1;
}
else
{
return 0;
}

}

void FindError(struct EngineerStruct *p1,struct EngineerStruct *head) //判断输入的工程师信息是否正确
{
while (((p1->EngineerNo<= 0) || (p1->EngineerNo >= 10

000)) || Find(head,p1->EngineerNo) == 1)
{
printf("工程师编号输入错误,请重新输入:\n");
scanf("%u",&p1->EngineerNo);
}

while(strlen(p1->EngineerName) == 0 || strlen(p1->EngineerName) > 20)
{
printf("工程师姓名输入错误,请重新输入:");
scanf("%s",p1->EngineerName);
}

while (p1->EngineerSex != 0 && p1->EngineerSex != 1)
{
printf("工程师性别输入错误,请重新输入:\n");
scanf("%d",&p1->EngineerSex);
}

while (p1->EngineerBirth.year<1900 || p1->EngineerBirth.year > 2004)
{
printf("工程师生日中的年输入错误,请重新输入:\n");
scanf("%d",&p1->EngineerBirth.year);
}

while (p1->EngineerBirth.month < 1 || p1->EngineerBirth.month > 12)
{
printf("工程师生日中的月输入错误,请重新输入:\n");
scanf("%d",&p1->EngineerBirth.month);
}

while (p1->EngineerBirth.day < 1 || p1->EngineerBirth.day > 31)
{
printf("工程师生日中的日输入错误,请重新输入:\n");
scanf("%d",&p1->EngineerBirth.day);
}

while (p1->EngineerEducation < 0 || p1->EngineerEducation > 4)
{
printf("工程师的学历输入错误,请重新输入:\n");
scanf("%d",&p1->EngineerEducation);
}

while(strlen(p1->EngineerHometown) == 0 || strlen(p1->EngineerHometown) > 10)
{
printf("工程师的籍贯输入错误,请重新输入:\n");
scanf("%s",p1->EngineerHometown);
}


while(strlen(p1->EngineerAddress) == 0 || strlen(p1->EngineerAddress) > 30)
{
printf("工程师的地址输入错误,请重新输入:\n");
scanf("%s",p1->EngineerAddress);
}

while(strlen(p1->EngineerPhone) == 0 || strlen(p1->EngineerPhone) > 15)
{
printf("工程师的电话输入错误,请重新输入:\n");
scanf("%s",p1->EngineerPhone);
}

while (p1->EngineerWorkYears < 0 || p1->EngineerWorkYears > 50)
{
printf("工程师的工龄输入错误,请重新输入:\n");
scanf("%d",&p1->EngineerWorkYears);
}

while (p1->EngineerBaseSalary ==0)
{
printf("工程师的基本薪水输入错误,请重新输入:\n");
scanf("%f",&p1->EngineerBaseSalary);
}
}

struct EngineerStruct* Input() //添加工程师信息
{
struct EngineerStruct *head = NULL;
struct EngineerStruct *p1 ,*p2;
p1 = p2 = (struct EngineerStruct *)malloc(sizeof(struct EngineerStruct));
scanf("%u %s %u %d %d %d %s %u %s %s %u %f",&p1->EngineerNo,p1->EngineerName,&p1->EngineerSex,
&p1->EngineerBirth.year,&p1->EngineerBirth.month,&p1->EngineerBirth.day,
p1->EngineerHometown,&p1->EngineerEducation,p1->EngineerAddress,p1->EngineerPhone,
&p1->EngineerWorkYears,&p1->EngineerBaseSalary);

while (p1->EngineerNo != 0)
{
FindError(p1,head);
n = n + 1;
if(n == 1)
{
head = p1 ;
p2 = p1 ;
p2->next = NULL;
}
else
{
p2->next = p1 ;
p2 = p1;
p2->next = NULL;
}
p1 = (struct EngineerStruct *)malloc(sizeof(struct Engi

neerStruct));
scanf("%u %s %u %d %d %d %s %u %s %s %u %f",&p1->EngineerNo,p1->EngineerName,&p1->EngineerSex,
&p1->EngineerBirth.year,&p1->EngineerBirth.month,&p1->EngineerBirth.day,
p1->EngineerHometown,&p1->EngineerEducation,p1->EngineerAddress,p1->EngineerPhone,
&p1->EngineerWorkYears,&p1->EngineerBaseSalary);
}
p2->next = NULL;
return head;
}

struct EngineerStruct *Delete(struct EngineerStruct *head,unsigned num) //删除指定工程师的信息
{
struct EngineerStruct *p1,*p2;
if(head == NULL)
{
printf("List is NULL\n");
return head;
}
p1 = head;
while(p1->EngineerNo != num && p1->next != NULL)
{
p2=p1;
p1=p1->next;
}
if(p1->EngineerNo == num)
{
if(p1 == head)
{
head = p1->next;
free(p1);
}
else
{
p2->next = p1->next;
free(p1);
}
printf("%u been delete!\n",num);
n--;
}
else
{
printf("%u not been found!\n",num);
}
return(head);
}

struct EngineerStruct *Select(struct EngineerStruct *head,unsigned num) //查询指定工程师的信息
{
struct EngineerStruct *p1,*p2;
if(head == NULL)
{
printf("List is NULL\n");
return head;
}
p1 = head;
while(p1->EngineerNo != num && p1->next != NULL)
{
p2=p1;
p1=p1->next;
}
if(p1->EngineerNo == num)
{

printf("EngineerNo:%u EngineerName:%s EngineerSex:%u EngineerBirth:%d-%d-%d EngineerHometown:%s EngineerEducation:%u EngineerAddress:%s EngineerPhone:%s EngineerWorkYears:%u EngineerBaseSalary:%f\n",
p1->EngineerNo,p1->EngineerName,p1->EngineerSex,p1->EngineerBirth.year,p1->EngineerBirth.month,p1->EngineerBirth.day,
p1->EngineerHometown,p1->EngineerEducation,p1->EngineerAddress,p1->EngineerPhone,p1->EngineerWorkYears,p1->EngineerBaseSalary);
}
else
{
printf("%u not been found!\n",num);
}
return(head);
}

struct EngineerStruct* Modify(struct EngineerStruct *head, unsigned num) //修改指定工程师信息
{
struct EngineerStruct *p1,*p2;
if(head == NULL)
{
printf("List is NULL\n");
return head;
}
p1 = head;
while(p1->EngineerNo != num && p1->next != NULL)
{
p2=p1;
p1=p1->next;
}
if(p1->EngineerNo == num)
{
printf("please input the new message of %u \n",num);
scanf("%s %u %d %d %d %s %u %s %s %u %f",p1->EngineerName,&p1->EngineerSex,
&p1->EngineerBirth.year,&p1->EngineerBirth.month,&p1->EngineerBirth.day,
p1->EngineerHometown,&p1->EngineerEducation,p1->EngineerAddress,p1->EngineerPhone,
&p1->EngineerWorkYears,&p1->EngineerBaseSalary);
}
else
{
printf("%u not been found!\n",num);
}
return(head);

}

struct EngineerStruct *Calculate(struct EngineerStruct *head,unsigned num) //计算工程师月薪水
{
struct EngineerStruct *p1,*p2;
if(head == NULL)
{
printf("List is NULL\n");
return head;
}
p1 = head;
while(p1->EngineerNo != num && p1->next != NULL)
{
p2=p1;
p1=p1->next;
}
if(p1->EngineerNo == num)
{
Salary=(p1->EngineerBaseSalary

+10*EngineerMonthWorkDays+EngineerMonthBenefit * (p1->EngineerWorkYears)/100)*0.9-EngineerMonthInsurance;
}
else
{
printf("%u not been found!\n",num);
}
return(head);
}

void Output(struct EngineerStruct *head) //打印所有工程师信息
{
struct EngineerStruct *p1;
p1 = head;
while (p1 != NULL)
{
printf("EngineerNo:%u EngineerName:%s EngineerSex:%u EngineerBirth:%d-%d-%d EngineerHometown:%s EngineerEducation:%u EngineerAddress:%s EngineerPhone:%s EngineerWorkYears:%u EngineerBaseSalary:%f\n",
p1->EngineerNo,p1->EngineerName,p1->EngineerSex,p1->EngineerBirth.year,p1->EngineerBirth.month,p1->EngineerBirth.day,
p1->EngineerHometown,p1->EngineerEducation,p1->EngineerAddress,p1->EngineerPhone,p1->EngineerWorkYears,p1->EngineerBaseSalary);
p1 = p1->next;
}
}

void AllDelete(struct EngineerStruct *head) //清空所有工程师信息
{
struct EngineerStruct *p1;
p1 = head;
while (p1 != NULL)
{
free(p1);
p1 = p1->next;
}
}

struct EngineerStruct *Print(struct EngineerStruct *head,unsigned num) //打印工程师报表
{
struct EngineerStruct *p1,*p2;
if(head == NULL)
{
printf("List is NULL\n");
return head;
}
p1 = head;
while(p1->EngineerNo != num && p1->next != NULL)
{
p2=p1;
p1=p1->next;
}
if(p1->EngineerNo == num)
{

printf("*******************************************************\n");
printf("*编号:%u *\n",p1->EngineerNo);
printf("*******************************************************\n");
printf("*姓名:%s *\n",p1->EngineerName);
printf("*******************************************************\n");
printf("*性别:%u *\n",p1->EngineerSex);
printf("*******************************************************\n");
printf("*生日:%d-%d-%d *\n",p1->EngineerBirth.year,p1->EngineerBirth.month,p1->EngineerBirth.day);
printf("*******************************************************\n");
printf("*籍贯:%u *\n",p1->EngineerHometown);
printf("*******************************************************\n");
printf("*学历:%u *\n",p1->EngineerEducation);
printf("*******************************************************\n");
printf("*地址:%u *\n",p1->EngineerAddress);
printf("*******************************************************\n");
printf("*电话:%u *\n",p1->EngineerPhone);
printf("*******************************************************\n");
printf("*工龄:%u *\n",p1->EngineerWorkYears);
printf("*******************************************************\n");
printf("*基本工资:%u

*\n",p1->EngineerBaseSalary);
printf("*******************************************************\n");
}
else
{
printf("%u not been found!\n",num);
}
return(head);
}


void main()
{
struct EngineerStruct *head = NULL;
int i;
unsigned num;
menu();
scanf("%d",&i);
while(i != -1)
{
switch(i)
{
case 1:
system("cls.exe");
printf("请输入要添加的工程师的资料:\n");
head = Input();
menu();
break;
case 2:
system("cls.exe");
printf("请输入要删除的工程师的编号:\n");
scanf("%u",&num);
head = Delete(head,num);
menu();
break;
case 3:
system("cls.exe");
printf("请输入要查询的工程师的编号:\n");
scanf("%u",&num);
head = Select(head,num);
menu();
break;
case 4:
system("cls.exe");
printf("请输入要修改的工程师的编号:\n");
scanf("%u",&num);
head = Modify(head,num);
menu();
break;
case 5:
system("cls.exe");
printf("请输入要计算月工资的工程师的编号:\n");
scanf("%u",&num);
head = Calculate(head,num);
menu();
break;
case 6:
system("cls.exe");
printf("保存新添加的工程师资料 未写!\n");
menu();
break;
case 7:
system("cls.exe");
printf("对测试工程师信息排序 未写!\n");
menu();
break;
case 8:
system("cls.exe");
printf("输出所有测试工程师信息:\n");
Output(head);
menu();
break;
case 9:
system("cls.exe");
printf("清空所有测试工程师信息:\n");
AllDelete(head);
menu();
break;
case 10:
system("cls.exe");
printf("打印工程师资料信息报表:\n");
head = Print(head,num);
menu();
break;
case 11:
system("cls.exe");
printf("从文件重新导入测试工程师数据 未写!\n");
menu();
break;
case 0:
system("cls.exe");
exit(0);
}
scanf("%d",&i);
}
}

相关文档
最新文档