用c语言输入一个程序,完成以下功能

来源:百度知道 编辑:UC知道 时间:2024/05/24 14:55:22
1)输入N个职工的姓名、性别、年龄、职工代号及职称
2)按职工的年龄进行排序
3)从键盘输入一个职工的代号,查找并输出该职工的记录

要求 :要使用结构体编程

谢谢!

今晚之前搞定~

#include <stdlib.h>
#include <string.h>
#include<stdio.h>
struct information{
int num,old;
char name[20],sex[20],pos[20];
struct information *next;
}*p,*head,*last,*forward;
/*新增员工函数*/void Input(struct information *head){
struct information *f,*b,*forward;
forward=(struct information*)malloc(sizeof(struct information));
printf("请输入新增职工的职工代号,姓名,性别,年龄,职称:\n");
scanf("%d %s %s %d %s",&forward->num,forward->name,forward->sex,&forward->old,forward->pos);
b=head;
f=head->next;
if(forward->old<head->old){
forward->next=head;
head=forward;}
else{
while((forward->old>f->old)&&(f->next!=NULL)){
b=f;f=f->next;}
forward->next=f;
b->next=forward;
}
}
/*按职工代号查找函数*/void Find(struct information *head){
stru