#include stdioh#include stdlibhstruct ListNode int data; struct ListNode next;;struct ListNode createlist; 裁判实现细节不表struct ListNode reverse struct ListNode head ;void printlist struct ListNode h
struct ListNode *createlist() { struct ListNode *head = NULL; struct ListNode *tail = NULL; int n;
scanf("%d", &n);
while (n != -1) {
struct ListNode *newNode = (struct ListNode*)malloc(sizeof(struct ListNode));
newNode->data = n;
newNode->next = NULL;
if (head == NULL) {
head = newNode;
tail = newNode;
} else {
tail->next = newNode;
tail = newNode;
}
scanf("%d", &n);
}
return head;
}
原文地址: http://www.cveoy.top/t/topic/jdMk 著作权归作者所有。请勿转载和采集!