总是有点毛病,大侠们帮帮忙呀
这是一个软件工程师管理系统。在运行时总是出现 “应用程序错误”!
帮帮忙看看怎么回事呀 !谢谢!
#include <stdio.h>
#define N 10
unsigned int menu(void);
void InputInformation(); /*输入信息*/
void DeleteInformation(); /*删除信息*/
void SearchInformation(); /*查询信息*/
void ModifyInformation(); /*修改信息*/
void CalculateSalary(); /*计算月薪水*/
void InfomationSave(void); /*保存信息*/
void InformationSort(void); /*信息排序*/
void OutputInfomation(); /*信息输出*/
void Delete(void); /*清空全部信息*/
void InfomationSaveAs(void); /*把信息另存为*/
void SystemOver(void); /*结束程序*/
enum Status{FALSE,TRUE};
enum Sex{male,female}; /*定义枚举类型 性别分类*/
enum Education{high,bachelor,master,docter,other}; /*定义枚举类型,学历分类*/
unsigned int ActualNum=0;
enum Status status;
void main(void)
{
unsigned int Select;
unsigned int EngineerNo[N];
unsigned int EngineerWorkYears[N];
float EngineerBaseSalary[N];
unsigned int EngineerMonthWorkDays[N];
double Salary[N];
float MonthInsurance;
float MonthBenefit;
unsigned int i=0;
while(1)
{
Select=menu();
switch(Select)
{
case 1:
printf("现在添加软件测试工程师的息资料\n");
InputInformation();
break;
case 2:
printf("把软件测试工程师所有资料信息清零\n");
DeleteInformation();
break;
case 3:
printf("现在搜索软件测试工程师信息资料\n");
SearchInformation();
break;
case 4:
printf("现在修改软件测试工程师信息资料\n");
ModifyInformation();
break;
case 5:
for(i=0; i<ActualNum; ++i)
{
status=FALSE;
while(!status)
{
printf("请输入编号为%d的工程师月有效工作天数:",EngineerNo[i]);
scanf("%d",&EngineerMonthWorkDays[i]);
if(0==EngineerMonthWorkDays[i] || 31<EngineerMonthWorkDays[i])
{
status=FALSE;
printf("月有效工作天数不能等于0或大于31天!\n");
continue;
}
else
status=TRUE;
}
}
printf("请输入月效益和月保险金\n");
scanf("%f%f",&MonthBenefit,&MonthInsurance);
CalculateSalary();
for(i=0; i<ActualNum; ++i)
printf("编号为%d的工程师的当月薪水是%f\n",EngineerNo[i],Salary[i]);
break;
case 6:
InfomationSave();
break;
case 7:
InformationSort();
break;
case 8:
OutputInfomation();
break;
case 9:
Delete();
break;
case 10:
InfomationSaveAs();
break;
case 0:
SystemOver();
break;
default:
printf("您的选择输入不正确!\n");
}
if( 0==Select)
break;
}
}
/*********************************************************************************
打印系统的菜单
**********************************************************************************/
unsigned int menu(void)
{
unsigned int selection;
printf("\n\t--------------------------------------------------------\n");
printf("\t|\t\t软件测试工程师管理系统\t\t\t|\n");
printf("\t--------------------------------------------------------\n\n");
printf("\t1.输入软件测试工程师资料\n");
printf("\t2.删除软件测试工程师资料\n");
printf("\t3.搜索软件测试工程师资料\n");
printf("\t4.修改软件测试工程师资料\n");
printf("\t5.计算工程师的月薪水\n");
printf("\t6.保存新添加的工程师资料\n");
printf("\t7.工程师信息排序('1 编号升序, 2 姓名升序,3 工龄升序)\n");
printf("\t8.输出工程师信息数据\n");
printf("\t9.清空数据\n");
printf("\t10.把软件测试工程师数据另保存\n");
printf("\t0.结束(添加新工程师需要保存)\n\n\n");
printf("\t请输入您的选择:");
scanf("%d",&selection);
return selection;
}
/*输入软件测试工程师资料*/
void InputInformation( unsigned int EngineerNo[]
,unsigned int EngineerSex[]
,unsigned int EngineerEducation[]
,float EngineerBaseSalary[]
,unsigned int EngineerWorkYears[])
{ int i=0;
char yn;
for(i=ActualNum; i<N; ++i)
{
printf("--------------------------------------------------------\n");
printf("要输入第%d个工程师信息吗?(y或者n)\n",i+1);
fflush(stdin);
scanf("%c",&yn);
if('n'==yn)
break;
if('y'==yn)
{
status=FALSE;
ActualNum++;
while( !status )
{
fflush(stdin);
printf("请输入工程师的编号:");
fflush(stdin);
scanf("%d",&EngineerNo[i]);
if(0==EngineerNo[i])
{
status=FALSE;
printf("编号要不能等于0!\n");
continue;
}
else
status=TRUE;
fflush(stdin);
printf("请输入工程师的性别:(0->女,1->男)");
scanf("%d",&EngineerSex[i]);
if(0!=EngineerSex[i] && 1!=EngineerSex[i])
{
status=FALSE;
printf("性别只能输入0或1!\n");
continue;
}
else
status=TRUE;
printf("请输入工程师的学历(0->high,1->bachelor,2->master,3->docter,4->other):");
scanf("%d",&EngineerEducation[i]);
if( 4<EngineerEducation[i] || 0>EngineerEducation[i])
{
status=FALSE;
printf("学历只能是 0,1,2,3,4\n");
continue;
}
else
status=TRUE;
printf("输入工程师的工龄:");
scanf("%d",&EngineerWorkYears[i]);
if( 0==EngineerWorkYears[i] || 50<EngineerWorkYears[i])
{
status=FALSE;
printf("工龄不能为0或大于50年!\n");
continue;
}
else
status=TRUE;
printf("请输入工程师的基本工资:");
fflush(stdin);
scanf("%f",&EngineerBaseSalary[i]);
if(0==EngineerBaseSalary[i])
{
status=FALSE;
printf("基本工资不能等于0!\n");
continue;
}
else
status=TRUE;
}
printf("--------------------------------------------------------\n");
}
else
break;
}
}
/*删除软件测试工程师资料*/
void DeleteInformation( unsigned int EngineerNo[]
,unsigned int EngineerSex[]
,unsigned int EngineerEducation[]
,float EngineerBaseSalary[]
,unsigned int EngineerWorkYears[])
{
unsigned int no;
unsigned int i=0;
enum Status sta=FALSE;
char yn;
printf("请输入要删除的工程师的编号\n");
fflush(stdin);
scanf("%d",&no);
for(i=0; i<ActualNum; ++i)
{
if(no==EngineerNo[i])
{
printf("您确认要删除该工程师的信息吗?(y或n)\n");
fflush(stdin);
scanf("%c",&yn);
if('n'==yn)
break;
if('y'==yn)
{
EngineerNo[i]=0;
EngineerSex[i]=0;
EngineerEducation[i]=0;
EngineerBaseSalary[i]=0;
EngineerWorkYears[i]=0;
}
sta=TRUE;
}
}
if(!sta)
printf("您要删除的工程师信息不存在!");
}
/*********************搜索软件测试工程师资料*******************/
void SearchInformation()
{
printf("工程师信息排序功能还没有实现!\n");
}
/*********************修改软件测试工程师资料******************/
void ModifyInformation( unsigned int EngineerNo[]
,unsigned int EngineerSex[]
,unsigned int EngineerEducation[]
,float EngineerBaseSalary[]
,unsigned int EngineerWorkYears[])
{
unsigned int no;
unsigned int i=0;
enum Status sta=FALSE;
printf("请输入要修改的工程师的编号:\n");
fflush(stdin);
scanf("%d",&no);
for(i=0; i<ActualNum; ++i)
{
if(no==EngineerNo[i])
{
status=FALSE;
while( !status )
{
printf("原来工程师的编号是%d,请输入修改后的编号:\n",EngineerNo[i]);
fflush(stdin);
scanf("%d",&EngineerNo[i]);
if(0==EngineerNo[i])
{
status=FALSE;
printf("编号要不能等于0!\n");
continue;
}
else
status=TRUE;
printf("原来工程师的性别是");
EngineerSex[i]==0? printf("女\n"):printf("男\n");
printf("请输入修改的工程师性别(0->女,1->男)");
fflush(stdin);
scanf("%d",&EngineerSex[i]);
if(0!=EngineerSex[i] && 1!=EngineerSex[i])
{
status=FALSE;
printf("性别只能输入0或1!\n");
continue;
}
else
status=TRUE;
printf("原来工程师的学历是:");
switch(EngineerEducation[i])
{
case 0:
printf("high\n");
break;
case 1:
printf("bachelor\n");
break;
case 2:
printf("master\n");
break;
case 3:
printf("docter\n");
break;
case 4:
printf("other\n");
break;
default:
break;
}
printf("请输入修改后工程师的学历:(0->high,1->bachelor,2->master,3->docter,4->other):");
fflush(stdin);
scanf("%d",&EngineerEducation[i]);
if( 4<EngineerEducation[i] || 0>EngineerEducation[i])
{
status=FALSE;
printf("学历只能是 0,1,2,3,4\n");
continue;
}
else
status=TRUE;
printf("原来工程师的基本工资是%f,请输入修改后的基本工资:",EngineerBaseSalary[i]);
fflush(stdin);
scanf("%f",&EngineerBaseSalary[i]);
if(0==EngineerBaseSalary[i])
{
status=FALSE;
printf("基本工资不能等于0!\n");
continue;
}
else
status=TRUE;
printf("原来工程师的工龄是%d,请输入修改后的值:\n",EngineerWorkYears[i]);
fflush(stdin);
scanf("%d",&EngineerWorkYears[i]);
if( 0==EngineerWorkYears[i] || 50<EngineerWorkYears[i])
{
status=FALSE;
printf("工龄不能为0或大于50年!\n");
continue;
}
else
status=TRUE;
}
sta=TRUE;
}
}
if(!sta)
printf("您要搜索的工程师信息不存在!");
}
/****************************************************************************
计算工程师月薪水
****************************************************************************/
void CalculateSalary( float EngineerBaseSalary[]
,unsigned int EngineerWorkYears[]
,unsigned int EngineerMonthWorkDays[]
,float MonthBenefit
,float MonthInsurance
,double Salary[])
{ unsigned int i=0;
for(i=0; i<ActualNum; ++i)
Salary[i]=(EngineerBaseSalary[i]+10*EngineerMonthWorkDays[i]+MonthBenefit*EngineerWorkYears[i]/100)*0.9-MonthInsurance;
}
/*************************保存新添加的工程师资料****************************/
void InfomationSave(void)
{
printf("保存新添加的工程师资料功能没有实现!\n");
}
/***************工程师信息排序('1 编号升序, 2 姓名升序,3 工龄升序)\n"******/
void InformationSort(void)
{
printf("工程师信息排序功能还没有实现!\n");
}
/*************************输出工程师的所有信息*****************************/
void OutputInfomation( unsigned int EngineerNo[]
,unsigned int EngineerSex[]
,unsigned int EngineerEducation[]
,float EngineerBaseSalary[]
,unsigned int EngineerWorkYears[]
,unsigned int EngineerMonthWorkDays[]
,double Salary[])
{
unsigned int i=0;
for(i=0; i<ActualNum; ++i)
{
printf("********************************************************************\n");
printf("软件测试工程师的信息如下:\n");
printf("编号:%d\n",EngineerNo[i]);
EngineerSex[i]==0? printf("性别:女\n"):printf("性别:男\n");
printf("工龄:%d\n",EngineerWorkYears[i]);
printf("工程师的学历是:");
switch(EngineerEducation[i])
{
case 0:
printf("high\n");
break;
case 1:
printf("bachelor\n");
break;
case 2:
printf("master\n");
break;
case 3:
printf("docter\n");
break;
case 4:
printf("other\n");
break;
default:
break;
}
printf("工程师的基本薪水是%f\n",EngineerBaseSalary[i]);
printf("工程师的当月工作天数是%d\n",EngineerMonthWorkDays[i]);
printf("工程师的当月薪水是%f\n",Salary[i]);
printf("********************************************************************\n");
}
}
/*清空数据*/
void Delete(void)
{
printf("功能没有实现!\n");
}
/*信息另存为*/
void InfomationSaveAs(void)
{
printf("功能没有实现!\n");
}
/*结束*/
void SystemOver(void)
{
printf("系统退出!\n");
}