求一道C语言设计题答案 职工信息管理系统

 职工信息包括职工号、姓名、性别、年龄、学历、工资、住址、电话等(职工号不重复)。
 试设计一职工信息管理系统,使之能提供以下功能:
a) 系统以菜单方式工作
b) 职工信息录入功能(职工信息用文件保存)--输入;
c) 职工信息浏览功能 --输出;
d) 查询和排序功能:(至少一种查询方式) --算法
(1) 按工资查询
(2) 按学历查询等

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

#define MAX 1000

struct man {
int account;/*职工编号*/
int sex;/*性别*/
int year;/*工龄*/
char school[30];/*学历*/
double base;/*基本工资*/
float complete;/*出勤率*/
double result;/*总工资*/
};

int MenuChoice(void);
void InsertList (struct man *fst, const struct man *p);
struct man *DeleteList(struct man *fd, int num);
struct man *SearchList(struct man *serch, int num);
void PrintList(const struct man *out, int sign);
int fcomp(const struct man * , const struct man * );
int scomp(const struct man * , const struct man * );

main()
{
struct man start[MAX] = , temp, *p;
int c, value;

while (c = MenuChoice()) {
switch (c) {
case 1:
printf("请分别输入职工号,性别(1-男, 2-女),工龄,学历,基本工资, 出勤率:\n");
scanf("%d %d %d %s %Lf %f", &temp.account, &temp.sex, &temp.year, &temp.school,
&temp.base, &temp.complete);
temp.result = (temp.base + 50 * temp.year) * temp.complete;/*计算总工资*/
InsertList(start, &temp);
break;
case 2:
case 3:
printf("请输入职工编号: ");
scanf("%d", &value);

if (p = SearchList(start, value)) {
if (c == 2) {
p->base = p->result = p->sex = p->account = p->year = (int)p->complete = 0;
strcpy(p->school, "");
}
else
PrintList(p, 0);
}
else
printf("对不起,该职工不存在!\n");

break;
case 4:
qsort(start, MAX, sizeof(struct man), (int (*)(const void *, const void *))fcomp);
break;
case 5:
qsort(start, MAX, sizeof(struct man), (int (*)(const void *, const void *))scomp);
break;
case 6:
PrintList(start, 1);
break;
}

fflush(stdin);
}

return 0;
}

void PrintList(const struct man *out, int sign)
{
const struct man *temp;

for (temp = out; out < &temp[MAX]; out++) {
if (out->account)
printf("\n职工号: %d\n性别: %s\n工龄: %d\n学历: %s\n基本工资: %.2Lf\n总工资: %.2Lf"
"\n\n", out->account, out->sex == 1 ? "男" : "女", out->year, out->school,
out->base, out->result);

if (sign == 0)
return ;
}

}

void InsertList (struct man *fst, const struct man *p)
{
struct man *temp = fst;

for (temp = fst; fst < &temp[MAX] && fst->account; fst++)
;

if (fst < &temp[MAX])
*fst = *p;
}

struct man *SearchList(struct man *serch, int num)
{
struct man *temp = serch;

while (serch < &temp[MAX] && serch->account != num)
serch++;

if (serch >= &temp[MAX])
return NULL;

return serch;
}

int MenuChoice(void)
{
int ret;

printf("1 - 新增职工管理信息\n"
"2 - 删除职工信息\n"
"3 - 按职工编号查找\n"
"4 - 按职工编号排序\n"
"5 - 按职工工资排序\n"
"6 - 打印工资信息\n"
"0 - 退出\n");
scanf("%d", &ret);

return ret;
}

int fcomp(const struct man *fele, const struct man *sele)
{
if (fele->account > sele->account)
return 1;
else if (fele->account < sele->account)
return -1;

return 0;
}

int scomp(const struct man *fele, const struct man *sele)
{
if (fele->result > sele->result)
return 1;
else if (fele->result < sele->result)
return -1;

return 0;
}
另外,站长团上有产品团购,便宜有保证追问

编译第47行出错了

温馨提示:答案为网友推荐,仅供参考
相似回答