标签:
void CreateListHead (LinkList *L,int n) { LinkList p; int i; srand(time(0)); //初始化随机数种子 *L = (LinkList)malloc(sizeof(Node)); (*L)->next = NULL; for (i = 0; i < n; i++) { p = (LinkList)malloc(sizeof(Node)); p->data = rand()%100+1; p->next = (*L)->next } }
3. 尾插法建立单链表
void CreateListTail (LinkList *L,int n) { LinkList p,r; int i; srand(time(0)); //初始化随机数种子 *L = (LinkList)malloc(sizeof(Node)); r = *L; for (i = 0; i < n; i++) { p = (Node *)malloc(sizeof(Node)); p->data = rand()%100+1; r->next = p; r = p; } r->next = NULL; }
标签:
原文地址:http://www.cnblogs.com/czq1989/p/5253468.html