提交记录 #509
提交时间:2024-12-17 13:34:13
语言:c
状态:CompileError
编译情况:编译错误
code.c: In function ‘main’:
code.c:18:4: warning: implicit declaration of function ‘gets’; did you mean ‘fgets’? [-Wimplicit-function-declaration]
18 | gets( sa );
| ^~~~
| fgets
code.c: At top level:
code.c:33:15: error: unknown type name ‘SNODE’
33 | void movenode(SNODE *head, int m) {
| ^~~~~
固定测试点暂不可用
附加测试点暂不可用
5959-64,H26
void movenode(SNODE *head, int m) {
SNODE *prev = head; // 前驱节点
SNODE *current = head->next; // 当前节点
// 遍历链表,找到值为 m 的节点
while (current != NULL) {
if (current->num == m) {
// 如果当前节点已经是链首,直接返回
if (prev == head) {
return;
}
// 将当前节点从链表中移除
prev->next = current->next;
// 将当前节点插入到链首
current->next = head->next;
head->next = current;
return;
}
prev = current;
current = current->next;
}
}