![]() |
#2
最左边那个2009-10-04 21:55
|

#include <iostream>
using namespace std;
struct book
{
int i;
int j;
struct book *nent;
};
int main()
{
book a,b,c,*p,*p1;
a.i=10;
a.j=4;
b.i=5;
b.j=7;
c.i=6;
c.j=400;
p=&a;
a.nent=&b;
b.nent=&c;
c.nent=NULL;
p1=p;
while(p1!=NULL)
{
cout<<p1->i<<endl<<p1->j<<endl;
p1=p1->nent;
}
return 0;
}
using namespace std;
struct book
{
int i;
int j;
struct book *nent;
};
int main()
{
book a,b,c,*p,*p1;
a.i=10;
a.j=4;
b.i=5;
b.j=7;
c.i=6;
c.j=400;
p=&a;
a.nent=&b;
b.nent=&c;
c.nent=NULL;
p1=p;
while(p1!=NULL)
{
cout<<p1->i<<endl<<p1->j<<endl;
p1=p1->nent;
}
return 0;
}
这段链表里面 p1=p1->nent;
为什么删除掉了p1=p1->nene;这句话就成为了死循环了?
这里面 p1=p1->nent;有什么用啊!
其他的我大概琢磨差不多了,但这句话想半天没想出来啥意思!!
谢谢,往高手指明一下!!
谢谢