You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

228 lines
3.7 KiB

6 years ago
#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 input_w_Doc(worker *head);
void delect_w_Doc(worker *head);
void fun1_w_Doc(worker *head);
void stor_w_Doc(worker *head);
6 years ago
void fun2_w_Doc(worker *head);
6 years ago
void fun_w_Doc(worker *head);
6 years ago
void print_w_Doc(worker *head);
6 years ago
int main()
{
worker *head;
head=create_w_Doc();
input_w_Doc(head);
delect_w_Doc(head);
fun1_w_Doc(head);
fun_w_Doc(head);
stor_w_Doc(head);
6 years ago
fun2_w_Doc(head);
6 years ago
print_w_Doc(head);
return 0;
}
worker *create_w_Doc()
{
6 years ago
printf(" *************************** \n");
printf(" * ְ<><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3> * \n");
printf(" *************************** \n");
6 years ago
worker *head,*p1,*p2;
length=0;
int num,work;
6 years ago
p1=(worker*)malloc(sizeof(worker));
6 years ago
head=p1;
6 years ago
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>š<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n\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);
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>!\n\n");
return head;
}
void input_w_Doc(worker *head)
{
worker *p1,*p2;
int n,i;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD>");
scanf("%d",&n);
if(n>length)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
return;
}
else
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>š<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
p2=(worker*)malloc(sizeof(worker));
scanf("%d%d",&p2->num,&p2->work);
p1=head;
while(p1!=NULL)
{
if(p1->num==p2->num)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d%d",&p2->num,&p2->work);
}
p1=p1->next;
}
p1=head;
for(i=0;i<n;i++)
{
p1=p1->next;
}
p2->next=p1->next;
p1->next=p2;
length++;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n\n");
return;
}
}
6 years ago
6 years ago
void delect_w_Doc(worker *head)
{
worker *p1,*p2;
int num;
p1=head->next;
p2=head;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫɾ<EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><EFBFBD>ţ<EFBFBD>");
scanf("%d",&num);
while(p1!=NULL)
{
if(p1->num==num)
{
p2->next=p1->next;
free(p1);
length--;
printf("ɾ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n\n");
return;
}
p1=p1->next;
p2=p2->next;
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n\n");
}
6 years ago
6 years ago
void fun1_w_Doc(worker *head)
{
worker *p1;
6 years ago
int num,work;
p1=head->next;
6 years ago
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ۼӵĹ<EFBFBD><EFBFBD>ţ<EFBFBD>");
scanf("%d",&num);
p1=head;
do
{
if(p1->num==num)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ۼӵĹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d",&work);
p1->work+=work;
6 years ago
printf("<EFBFBD>ɹ<EFBFBD>!\n\n");
6 years ago
return;
}
p1=p1->next;
}while(p1!=NULL);
6 years ago
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n\n");
return;
6 years ago
}
void fun_w_Doc(worker *head)
{
worker *p1,*p2;
6 years ago
int num,work;
6 years ago
p1=head;
6 years ago
p2=head;
for(p1=head;p1!=NULL;p1=p1->next)
{
for(p2=head;p2!=NULL;p2=p2->next)
{
if(p1->work>p2->work)
{
num=p1->num;
p1->num=p2->num;
p2->num=num;
work=p1->work;
p1->work=p2->work;
p2->work=work;
}
}
}
6 years ago
return;
}
void stor_w_Doc(worker *head)
{
6 years ago
worker *p1;
6 years ago
int n;
p1=head->next;
int i;
i=1;
while(p1!=NULL)
{
p1->ranking=i;
p1=p1->next;
i++;
}
6 years ago
}
void fun2_w_Doc(worker *head)
{
worker *p1,*p2;
p1=head;
6 years ago
int i,n;
6 years ago
for(p1=head;p1!=NULL;p1=p1->next)
{
for(p2=p1;p2!=NULL;p2=p2->next)
{
if(p1->work==p2->work)
{
p2->ranking=p1->ranking;
if(p1->num>p2->num)
{
p1->next=p2->next;
p2->next=p1;
}
}
}
}
6 years ago
}
void print_w_Doc(worker *head)
{
6 years ago
worker *p1;
if(p1=NULL)
6 years ago
{
printf("<EFBFBD>޼<EFBFBD>¼<EFBFBD><EFBFBD>");
return;
}
printf("<EFBFBD><EFBFBD>¼Ϊ<EFBFBD><EFBFBD>\n\n");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>\n");
6 years ago
p1=head->next;
6 years ago
do
{
6 years ago
printf("%d %d %d\n",p1->num,p1->work,p1->ranking);
p1=p1->next;
}while(p1!=NULL);
6 years ago
}