parent
1b752f1dbb
commit
bd47ba4a3a
@ -1,98 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
struct work_info
|
||||
{
|
||||
int num;
|
||||
int work;
|
||||
int ranking;
|
||||
struct work_info *next;
|
||||
};
|
||||
int length;
|
||||
typedef struct work_info worker;
|
||||
|
||||
worker *create_w_Doc();
|
||||
void fun_w_Doc(worker *head);
|
||||
void print_w_Doc(worker *head);
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
worker *head;
|
||||
head=create_w_Doc();
|
||||
fun_w_Doc(head);
|
||||
print_w_Doc(head);
|
||||
return 0;
|
||||
}
|
||||
|
||||
worker *create_w_Doc()
|
||||
{
|
||||
worker *head,*p1,*p2;
|
||||
length=0;
|
||||
int num,work;
|
||||
head=p1=(worker*)malloc(sizeof(worker));
|
||||
printf("请输入工号(请不要输入相同的工号)、工作量:\n");
|
||||
scanf("%d%d",&num,&work);
|
||||
while(num!=0)
|
||||
{
|
||||
p2=(worker*)malloc(sizeof(worker));
|
||||
p2->num=num;
|
||||
p2->work=work;
|
||||
p1->next=p2;
|
||||
p1=p2;
|
||||
length++;
|
||||
scanf("%d%d",&num,&work);
|
||||
}
|
||||
return head;
|
||||
}
|
||||
void fun_w_Doc(worker *head)
|
||||
{
|
||||
worker *p1,*p2;
|
||||
while(p1!=NULL)
|
||||
{
|
||||
for(p1=head;p1!=NULL;p1=p1->next)
|
||||
{
|
||||
for(p2=p1->next;p2!=NULL;p2=p2->next)
|
||||
if(p1->work<p2->work)
|
||||
{
|
||||
p1->next=p2->next;
|
||||
p2->next=p1;
|
||||
}
|
||||
p1=p1->next;
|
||||
}
|
||||
for(p2=p1->next;p2!=NULL;p2=p2->next)
|
||||
{
|
||||
if(p1->work==p2->work)
|
||||
{
|
||||
if(p1->num>p2->num)
|
||||
{
|
||||
p2->next=p1;
|
||||
p1->next=p2->next;
|
||||
p2=p1;
|
||||
}
|
||||
p1=p1->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void print_w_Doc(worker *head)
|
||||
{
|
||||
worker *p;
|
||||
if(p=NULL)
|
||||
{
|
||||
printf("无记录!");
|
||||
return;
|
||||
}
|
||||
printf("记录为:\n\n");
|
||||
printf("工号 工作量 名次\n");
|
||||
p=head->next;
|
||||
do
|
||||
{
|
||||
printf("%d %d %d\n",p->num,p->work,p->ranking);
|
||||
p=p->next;
|
||||
}while(p!=NULL);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in new issue