#include
#include
#include
using namespace std;
#define statue int
typedef struct Elemtype{
int e1;
int e2;
Elemtype *next;
} *Linktype;
//元素结构
typedef struct{
//直表元素结构。
int m;
Linktype e;
Elemtype *cur;
//current当前
}HeadL,*Linkheadl;
statue shuru(int n,HeadL *a)
{
int i,j,k;
Linktype p,q;
for(i=0;inext=NULL;
cin>>q->e1>>q->e2;
for(j=a[0].m;j;j--)
{
if(a[j].e-(q->e1))
{
for(;(a[j].cur)->next;a[j].cur=(a[j].cur)->next)
{
if(a[j].cur->e1>q->e1)
{
p=a[j].cur;
a[j].cur=q;
q->next=p;
a[j].cur=a[j].e;
break;
}//if
}//for
if(!q->next) a[j].cur->next=q;
}//if
if(!(j-1))
{
a[0].m++;
k=a[0].m;
a[k].m=q->e1;
}//if
}//for
}//for
k=a[0].m;
HeadL h;
for(i=k-1;i;i--)
{
for(j=1;ja[j+1].m) {h=a[j];a[j]=a[j+1];a[j+1]=h;}
}//for
}//for
return 0;
}// 输入
statue shuchu(HeadL *L)
{
int i,k,j,n=L[0].m;
Elemtype *elem;
for(j=1;n;j++)
{
coute1e1e2next;
if(!L.cur)n--;
}//for
}//for
return 0;
}
int main()
{
int n;
HeadL a[2000];
a[0].m=1;a[1].m=0;a[1].e=NULL;a[1].cur=NULL;
cin>>n;
shuru(n,a);
shuchu(a);
system("pause");
return 0;
}
|