void LinkList::Ring(int i)
{
Node *pre=first,p=pre->next;
int count=2;
while(p!=pre)
{
if(count==i)
{
cout<data< pre=p->next;
delete p;
p=pre->next;
count=2;
}
else
{
pre=pre->next;
p=p->next;
count++;
}
}
cout<data;
delete p;
}
请大家帮忙看一下程序的问题?不知道是不是while(p!=pre)那里有问题
没仔细看,目测pre=p->next;
这里少了
pre->next = p->next->next;
不知道你的链表是否有头结点,如果有头结点,while(p!=pre)是不对的;如果没有头结点,while(p!=NULL&&pre!=NULL&&p!=pre)。
if(count==i)
{
coutnext;//这里应该是cout<next;