int josephus(LinkList* head, int n, int m) { LinkList* p = head; for (int i = 1; i < n; i++) p = p->next; while (p != NULL&& head->next != head) { for (int i = 1; i < m - 1; i++) p = p->next; LinkList* q = p->next; p->next = q->next; printf("%d ", q->data); free(q); p = p->next; } printf("%d ", head->data); free(head); return 0; }该vs2022c语言代码报错为:引发了未经处理的异常,读取访问权限冲突
时间: 2023-06-04 20:08:17 浏览: 85
) { LinkList* q = p->next; for (int j = 1; j < m; j ) { p = q; q = q->next; if (p == NULL) { p = head; } } p->next = q->next; delete q; p = p->next; } return p->data; }
这是一个关于约瑟夫问题的代码实现,请问这段代码的功能是什么?
阅读全文