主题:编译没问题,运行后为什么说不能READ
#include <iostream>
using namespace std;
typedef struct node{
int data;
struct node *next;
}lnode,linklist;
void createlist_tou(linklist *l,int n);
void display(linklist *l);
int main()
{int i;
linklist *l1;
cout<<"enter the number:\n";
cin>>i;
createlist_tou(l1,i);
display(l1);
return 0;
}
void createlist_tou(linklist *l,int n)
{
l=new lnode;
l->next=NULL;
linklist *p;
cout<<"请输入单链表:"<<endl;
for(int i=n;i>0;i--)
{
p=new lnode;
cin>>p->data;
p->next=l->next;
l->next=p;
}
}
void display(linklist *l)
{
linklist *p1;
p1=l->next;
cout<<"链表为:";
while(p1!=NULL)
{
cout<<p1->data<<" ";
p1=p1->next;
}
cout<<endl;
}
using namespace std;
typedef struct node{
int data;
struct node *next;
}lnode,linklist;
void createlist_tou(linklist *l,int n);
void display(linklist *l);
int main()
{int i;
linklist *l1;
cout<<"enter the number:\n";
cin>>i;
createlist_tou(l1,i);
display(l1);
return 0;
}
void createlist_tou(linklist *l,int n)
{
l=new lnode;
l->next=NULL;
linklist *p;
cout<<"请输入单链表:"<<endl;
for(int i=n;i>0;i--)
{
p=new lnode;
cin>>p->data;
p->next=l->next;
l->next=p;
}
}
void display(linklist *l)
{
linklist *p1;
p1=l->next;
cout<<"链表为:";
while(p1!=NULL)
{
cout<<p1->data<<" ";
p1=p1->next;
}
cout<<endl;
}