#include<iostream.h>
#include<stdlib.h>
#define elemtype int
#define null 0
typedef struct lnode
{
elemtype data;
struct lnode *next ;
}lnode,*list;
void creatlist(list &l,int n)
{
struct lnode *p;
l=(list)malloc(sizeof(lnode));
l->next=null;
for(int i=n;i>0;i--)
{
p=(list)malloc(sizeof(lnode));
int e;
e=i;
//cin>>e;
p->data=e;
p->next=l->next;
l->next=p;
}
}
void shuchu(list l, int i)
{
int e,j=0;
struct lnode *p;
p=l;//->next;
while( p && j<i)
{
j++;
p=p->next;
e=p->data;
cout<<e<<" ";
}
}
void main()
{
list obj;
int i;
i=5;
creatlist(obj,i);
shuchu(obj,i);
cout<<endl;
}
#include<stdlib.h>
#define elemtype int
#define null 0
typedef struct lnode
{
elemtype data;
struct lnode *next ;
}lnode,*list;
void creatlist(list &l,int n)
{
struct lnode *p;
l=(list)malloc(sizeof(lnode));
l->next=null;
for(int i=n;i>0;i--)
{
p=(list)malloc(sizeof(lnode));
int e;
e=i;
//cin>>e;
p->data=e;
p->next=l->next;
l->next=p;
}
}
void shuchu(list l, int i)
{
int e,j=0;
struct lnode *p;
p=l;//->next;
while( p && j<i)
{
j++;
p=p->next;
e=p->data;
cout<<e<<" ";
}
}
void main()
{
list obj;
int i;
i=5;
creatlist(obj,i);
shuchu(obj,i);
cout<<endl;
}