标签:
struct ListNode { int val; ListNode *next; }; ListNode* createListFromHead() { ListNode *list = (ListNode*)malloc(sizeof(ListNode)); list->next = NULL; ListNode *s; int x; while (cin >> x) { s = (ListNode*)malloc(sizeof(ListNode)); s->val = x; s->next = list->next; list->next = s; } return list; } ListNode* createListFromTail() { ListNode *list = (ListNode*)malloc(sizeof(ListNode)); list->next = NULL; ListNode *s; int x; ListNode *p = list; while (cin >> x) { s = (ListNode *)malloc(sizeof(ListNode)); s->val = x; p->next = s; p = s; } p->next = NULL; return list; }
以后再补!!!
标签:
原文地址:http://www.cnblogs.com/gattaca/p/4415591.html