回复 14楼 林月儿
程序代码:
int m,counter=2; ListNode *s; ListNode *Q; s = Q = NULL; s = head->next; printf("请输入一个正整数作为报数上限值"); scanf_s("%d",&m); if (m == 1) { q->next = head->next; free(head); } else { do { while (counter < m) { s = (LinkList)malloc(sizeof(ListNode)); s = s->next; counter++; } if (counter == m)//我觉得吧,counter等于m只会有一次相当于y=x和y=n交点只能有一个 { Q = (LinkList)malloc(sizeof(ListNode)); Q = s; s = head; while (s->next != Q) s = s->next; s->next = Q->next; free(Q); } counter=0;//这里将counter重新清零,能不能改正它们只有一次相等的错误? } while (s->next = NULL);//循环链表下一结点怎么会空?(我想的是最后删除的只剩下一个节点了,此时这个节点的指针域一定是空啊。其实这里我是想表达就剩下一个节点了) } return s;