using namespace std;
typedef struct SLnode
{
int data;
struct SLnode* next;
}SLnode;
void crealist(SLnode &head,int a[],int n)
{
head=(SLnode)malloc(sizeof(SLnode));
SLnode *p=head;
SLnode x;
for(int i =0;i<n;i++)
{
x=(SLnode)malloc(sizeof(SLnode));
x->data=a[i];
x->next=NULL;
p->next=x;
p=x;
}
}
void remake(SLnode *&head)
{
SLnode *p,*q;
p=head->next;
head->next=NULL;
while(p!=NULL)
{
q=p->next;
p->next=head->next;
head->next=p;
p=q;
}
}
int main()
{
int a[]={1,2,3,4,5};
int o =5;
SLnode *p;
crealist(p,a,o);
remake§;
SLnode *x=p->next;
while(x!=NULL)
{
std::cout << x->data << std::endl;
x=x->next;
}
}