1#include <iostream>2 3#include <time.h>4#include <stdlib.h>5 6 using namespacestd;7 8 #defineOK 19 #defineTRUE 1Ten #defineFALSE 0 One #defineERROR 0 A -typedefintStatus//the returned status value -typedefintElemtype;//types of data in a node the - //Data Structure -typedefstructNode - { +Elemtype data;//Data -Node *next;//pointer to next node + }node; AtypedefstructNode *sqlist; at - //single-Link table creation, head interpolation -Status Greatlisthead (SqList *l,intN) - { - Srand ((unsigned) time (NULL)); - sqlist p; in(*l) = (sqlist) malloc (sizeof(Node)); -(*l)->next=NULL; to for(intI=0; i<n;++i) + { -p= (sqlist) malloc (sizeof(Node)); theP->data=rand ()%Ten+1; *p->next= (*L)Next; $(*l)->next=p;Panax Notoginseng } - return 1; the } + A the intMain () + { - sqlist l,p; $Greatlisthead (&l,Ten); $p=L; - for(intI=0;i<Ten; i++) - { thecout<<p->next->data<<' '; -P=p->Next;Wuyi } thecout<<Endl; - WuSystem"Pause"); - return 1; About $}
Big talk data structure--linear table-chain storage head interpolation to create a linked list