/*纯排序,没有其它的东西*/
#include<iostream>
#include<malloc.h>
using namespace std;
struct teacher
{
char temp;
char name[50];
int count;
struct teacher *next;
};
/*创建链表*/
struct teacher *creat()
{
struct teacher *p,*q,*head;
p = (struct teacher *)malloc(sizeof(struct teacher));
head = p;
while(cin>>p->temp>>p->name>>p->count)
{
if(p->temp == 'v') p->count = p->count*30+3000;
if(p->temp == 'p') p->count = p->count*50+5000;
if(p->temp == 'l') p->count = p->count*20+2000;
q = p;
p = (struct teacher *)malloc(sizeof(struct teacher));
q->next = p;
}
q->next = NULL;
return head;
}
/*排序*/
struct teacher *play(struct teacher *head)
{
struct teacher *p,*p1,*p2,*p3;
struct teacher h, t;
if (head == NULL) return NULL; h.next = head;
p = &h;
while (p->next != NULL)
{
p = p->next;
}
p = p->next=&t;
while (p != h.next)
{
p3 = &h;
p1 = p3->next;
p2 = p1->next;
while (p2 != p)
{
if ((p1->count)<(p2->count))/*此处开始排序*/
{
p1->next = p2->next;
p2->next = p1;
p3->next = p2;
p3 = p2;
p2 = p1->next;
}
else
{
p3 = p1;
p1 = p2;
p2 = p2->next;
}
}
p = p1;
}
while (p->next != &t)
{
p = p->next;
}
p->next = NULL;
return h.next;
}
void out(struct teacher *head)
{
struct teacher *p;
p = head;
while(p != NULL)
{
cout<<p->name<<' '<<p->count<<endl;
p = p->next;
}
}
int main()
{
struct teacher *head;
head = creat();
head = play(head);
out(head);
return 0;
}