求高手解答。第十行本人把s的值给t后,在第十二行改变s->prior,为什么t 的prior也会变,t 不是应该保存在第十行的s的诗句不变吗。
void inversion(node *&L) { node *s = L->prior,*t; node *M,*last; M = new node; last = M; while(s != L) { t = s; last->next = s; s->prior = last; last = s; M->prior = last; last->next = M; s = t-prior; } delete L; L = M; }
解决方案
30
s没向后移,s和t指向同一个节点啊
10
你把s=t->prior;这句写在t=s;之后就是你要的效果了
40