#include <iostream>
using namespace std;
class NODE
{
public:
int data;
NODE *next;
};
void fun(NODE *list,int x)
{
NODE *u,*v,*p;
u=list;
v=u->next;
while(v!=NULL&&x<v->data)
{
u=v;
v=v->next;
}
if(v==NULL||x>v->data)
{
p=new NODE;
p->data=x;
p->next=v;
u->next=p;
}
}
void main()
{
int x;
NODE *head,*p;
head=new NODE;
head->next=NULL;
cout<<"Enter integers,end with 0"<<endl;
while(1)
{
cin>>x;
if(x==0)
break;
fun(head,x);
}
for(p=head->next;p!=NULL;p=p->next)
do{
p=head->next;
delete head;
head=p;
}while(p);
}
吃鸡游戏
相关分类