帮我修改一下程序
这个是一个通讯录的程序:#include<iostream.h>#include<malloc.h>
#define LEN sizeof(worker)
struct worker
{ long num;
char name[20];
char sex[10];
char age[10];
char WD[80];
char AD[80];
char Tel[20];
char guTel[20];
char email[80];
worker *next;
};
int n;
worker *creat()
{
worker *head;
worker *p1,*p2;
n=0;
p1=p2=(worker *)malloc(LEN);
cin>>p1->num;
getchar();
cin>>p1->name;
getchar();
cin>>p1->sex;
getchar();
cin>>p1->age;
getchar();
cin>>p1->WD;
getchar();
cin>>p1->AD;
getchar();
cin>>p1->Tel;
getchar();
cin>>p1-> guTel;
getchar();
cin>>p1->email;
getchar();
head=NULL;
while(p1->num!=0)
{
n=n+1;
if (n==1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=(worker *)malloc(LEN);
cin>>p1->num;
getchar();
cin>>p1->name;
getchar();
cin>>p1->sex;
getchar();
cin>>p1->age;
getchar();
cin>>p1->WD;
getchar();
cin>>p1->AD;
getchar();
cin>>p1->Tel;
getchar();
cin>>p1-> guTel;
getchar();
cin>>p1->email;
getchar();
}
p2->next=NULL;
return(head);
}
void list(worker *head)
{
worker *p;
cout<<endl<<"Now,These "<<n<<" records are:"<<endl;
p=head;
if(head!=NULL)
do
{
cout<<p->num<<" "<<p->name<<" "<<p->sex<<" "<<p->age<<" "<<p->WD
<<" "<<p->AD<<" "<< p->Tel<<" "<<p->guTel<<" "<<p->email<<endl;
p=p->next;
}while(p!=NULL);
}
worker *find(worker *head,long num)
{
int a;
worker *p1;
int k=0;
p1=head;
if(head==NULL)
{cout<<"记录表为空!"<<endl;return head;}
while(p1!=NULL)
{
if(p1->num==a)
{
cout<<"此人信息为:"<<endl;
cout<<"学号:"<<p1->num<<endl;
cout<<"姓名:"<<p1->name<<endl;
cout<<"性别:"<<p1->sex<<endl;
cout<<"年龄:"<<p1->age<<endl;
cout<<"工作单位:"<<p1->WD<<endl;
cout<<"通讯地址:"<<p1->AD<<endl;
cout<<"移动电话:"<<p1->Tel<<endl;
cout<<"固定电话:"<<p1->guTel<<endl;
cout<<"邮箱:"<<p1->email<<endl;
k=1;
}
p1=p1->next;
}
if(k==0)
cout<<"无此人!"<<endl;
}
main()
{
worker *head,*stu;
long find_num;
cout<<"input records:"<<endl;
head=creat();
find(head);
list(head);
cout<<endl<<"input the find number:";
cin>>find_num;
getchar();
list(head);
getchar();
}
多谢个位的帮忙!