提交记录 #506
提交时间:2024-12-17 13:26:38
语言: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:14: error: unknown type name ‘PNODE’
33 | int ins_list(PNODE head, int num) {
| ^~~~~
固定测试点暂不可用
附加测试点暂不可用
5959-64,H26
int ins_list(PNODE head, int num) {
PNODE p = head;
// 创建新节点
PNODE newNode = (PNODE)malloc(sizeof(NODE));
if (newNode == NULL) {
return 0; // 内存分配失败
}
newNode->data = num;
newNode->next = NULL;
// 找到链表的末尾
while (p->next != NULL) {
p = p->next;
}
// 将新节点插入到链表末尾
p->next = newNode;
return 1; // 插入成功
}