#include"stdio.h"
struct employee
{
int en;
int salary;
}
main()
{
int a,EN,SALARY;
int i=0;
struct employee emp[4];
printf("[1]input informations of employees\n");
printf("[2]show the salary information when input the employee id\n");
printf("[3]modify salary information\n");
printf("[4]delete salary information\n");
printf("[5]show all the employees's informations when input the department id\n");
printf("[6]exit\n");
printf("choose the operation id:");
while((a=getchar())!='6')
{
if(a=='1')
{
printf("employee id:\t");
scanf("%d",&EN);
printf("salary:\t");
scanf("%d",&SALARY);
while(EN>=1&&EN<=3&&SALARY>=0&&i<3)
{
emp[EN].en=EN;
emp[EN].salary=SALARY;
++i;
printf("employee id:\t");
scanf("%d",&EN);
printf("slary:\t");
scanf("%d",&SALARY);
}
}
else if(a=='2')
{
printf("employee id:\t");
scanf("%d",&EN);
printf("the slary of employee%d is %d\n",EN,emp[EN].salary);
}
else if(a=='3')
{
printf("employee id:\t");
scanf("%d",&EN);
printf("modify salary:\t");
scanf("%d",&SALARY);
emp[EN].salary=SALARY;
}
else if(a=='4')
{
printf("employee id:\t");
scanf("%d",&EN);
emp[EN].salary=-1;
printf("delete successfully :)\n");
}
else if(a=='5')
{
for(i=1;i<4;i++)
printf("employee id:%d\tsalary:%d\n",emp[i].en,emp[i].salary);
}
printf("choose the operation id:");
}
}
注:1,为了测试程序方便数据没有弄得太大
2,employee id 是1到3之间的整数(在录入职工工资信息时应该是只录入3次就好了,但我这代码得输入4次,但不影响其他操作)
3,部门的问题没有考虑
4,我是新手 还请高手多多指教
5,祝大家共同进步 :)