#include<stdio.h>
typedef struct student
{
int ID;
int grade;
struct student*next;
}student,*Pnode;
void createlink(Pnode head,int t)
{
Pnode tail=head;
tail->next=NULL;
for(int i=0;i<t;i++)
{
Pnode Node=(Pnode)malloc(sizeof(student));
tail->next=Node;
Node->next=NULL;
tail=Node;
scanf("%d %d",&Node->ID,&Node->grade);
}
}
Pnode sort(Pnode head,int len)
{ Pnode p,q;int i,j;
for(i=0,p=head->next;i<len-1;++i,p=p->next)
for(j=i+1,q=p->next;j<len;++j,q=q->next)
{ if(p->ID>q->ID)
{int t,m;
t=p->ID;
p->ID=q->ID;
q->ID=t;
m=p->grade;
p->grade=q->grade;
q->grade=m;