文章
246
粉丝
0
获赞
1179
访问
73.7k
#include<iostream>
using namespace std;
int n;
struct node{
int val;
node *next;
};
void init(node *l)
{
l->val=-5001;
l->next=NULL;
}
void sort(node *l)
{
int x;
node *p=l->next;
while(cin>>x)
{
node *q=new node;
q->val=x;
if(p->val<x)
{
q->next=p->next;
p->next=q;
p=q;
}
else
{
node *pre=l,*cur=l->next;
while(cur!=NULL)
{
if(pre->val<=x&&cur->val>x)
break;
pre=cur;
cur=cur->next;
}
q->next=pre->next;
pre->next=q;
}
}
}
int main()
{
cin>>n;
node *head=new node;
init(head);
int x;
cin>>x;
node *p=new node;
p->val=x;
p->next=head->...
登录后发布评论
暂无评论,来抢沙发