求大神知道 关于链表问题
#include<stdio.h>#include<stdlib.h>
#define LEN sizeof(struct member)
struct member
{
int num;
char name[20];
char sex[1];
double basePay;
double postPay;
double housePay;
double incomeTax;
double waterCost;
double reayPay;
struct member *next;
};
int menu();
void LookThrough(struct member *head); //浏览信息
void FindInform(); //查找指定员工
void Delete(); //删除员工信息
void AddInform(); //添加新员工
void AmendInform(); //修改员工信息
void Calaulate(); //计算工资
void Statistic(); //统计
void SaveInform(); //保存信息
struct member *creat() // ID号、姓名、基础工资、职务工资、住房公积金、个人收入所得税,水电费、实发工资。
{
int temp = 0;
struct member *head;
struct member *p1, *p2;
p1 = p2 =(struct member *) malloc(LEN);
printf("请输入ID号码\n");
scanf("%d",&p1->num);
while(p1->num != 0)
{
printf("请输入姓名\n");
scanf("%s",p1->name);
fflush(stdin);
printf("请输入性别(m/f)\n");
scanf("%s",p1->sex);
fflush(stdin);
printf("请输入基础工资\n");
scanf("%d",&p1->basePay);
printf("请输入职务工资\n");
scanf("%d",&p1->postPay);
printf("请输入住房公积金\n");
scanf("%d",&p1->housePay);
printf("请输入个人所得税\n");
scanf("%d",&p1->incomeTax);
printf("请输入水电费\n");
scanf("%d",&p1->waterCost);
head = NULL;
temp++;
p2 = p1;
p1 =(struct member *) malloc(LEN);
printf("请输入ID号码\n");
scanf("%d",&p1->num);
}
p2->next = NULL;
return (head);
}
int main()
{
int choice;
struct member *head;
printf("\t\t\t 欢迎登陆职工工资管理系统 \n");
printf("\n");
choice = menu();
switch(choice)
{
case 1: printf("您已进入职工信息录入系统\n");
head = creat();
LookThrough(head);
break;
case 2: printf("职工信息显示\n");
LookThrough(head);
break;
case 3: printf("您已进入职工信息查找系统\n");
break;
case 4: printf("您已进入职工信息删除系统\n");
break;
case 5: printf("您已进入新职工信息添加系统\n");
break;
case 6: printf("您已进入职工信息修改系统\n");
break;
case 7: printf("您已进入职工工资计算系统\n");
break;
case 8: printf("您已进入职工工资统计系统\n");
break;
case 9: printf("保存职工信息\n");
case 10:
break;
default: printf("输入有误, 请按照提示输入!\n");
}
return 0;
}
int menu()
{
int choice;
printf("\t\t*********************************************\n");
printf("\t\t---------------------------------------------\n");
printf("\t\t*** 1.职工信息录入 ***\n");
printf("\t\t*** 2.职工信息显示 ***\n");
printf("\t\t*** 3.职工信息查找 ***\n");
printf("\t\t*** 4.职工信息删除 ***\n");
printf("\t\t*** 5.新职工信息添加 ***\n");
printf("\t\t*** 6.职工信息修改 ***\n");
printf("\t\t*** 7.计算职工各项工资 ***\n");
printf("\t\t*** 8.统计职工工资信息 ***\n");
printf("\t\t*** 9.保存职工信息 ***\n");
printf("\t\t*** 10.退出 ***\n");
printf("\t\t---------------------------------------------\n");
printf("\t\t*********************************************\n");
printf("请输入您的选择:\n");
scanf("%d",&choice);
return choice;
}
void LookThrough(struct member *head)
{
struct member *p;
p = head;
if( head != NULL)
{
do
{
printf("%d%s%lf%lf%lf%lf%lf%lf",p->num, p->name, p->basePay, p->postPay, p->housePay, p->incomeTax, p-
>waterCost, p->reayPay);
p = p->next;
}while(p != NULL);
}
}
这个函数不好使 为什么啊 LookThrough(head)