\r
while (current != NULL)\r
{\r
- printf("%d\n", current->val);\r
+ printf("[%u] %d\n", current->id, current->val);\r
current = current->next;\r
}\r
}\r
void pushe(node_t * head, int val)\r
{\r
node_t * current = head;\r
+ current->id = head->id;\r
+ current->next->id = current->id+1;\r
+\r
while (current->next != NULL)\r
{\r
+ current->next->id = current->id;\r
current = current->next;\r
+ current->id++;\r
}\r
\r
// now we can add a new variable\r
current->next = malloc(sizeof(node_t));\r
current->next->val = val;\r
current->next->next = NULL;\r
+ current->next->id++;\r
}\r
\r
void pushs(node_t ** head, int val)\r
{\r
int i;\r
node_t * head = NULL; node_t * heao = NULL;\r
- node_t * nx = NULL;\r
head = malloc(sizeof(node_t)); heao = malloc(sizeof(node_t));\r
head->val = 0; heao->val = 9;\r
head->next=NULL; heao->next=NULL;\r
+ head->id=0; heao->id=0;\r
\r
- nx = head;\r
for(i=1; i<\r
//PAL_SIZE\r
- 5\r
+ 7\r
; i++)\r
{\r
- printf(" i=%d\n", i);\r
- pushe(nx, i);\r
- nx = nx->next;\r
+ if(!(i%3)) printf("\n ");\r
+ printf("%d,", i);\r
+ pushe(head, i);\r
}\r
- nx->next = NULL;\r
\r
- nx = heao;\r
+ printf("\n");\r
+\r
for(i=8; i>0; i--)\r
{\r
- printf(" i=%d\n", i);\r
- pushe(nx, i);\r
- nx = nx->next;\r
+ if(!(i%3)) printf("\n ");\r
+ printf("%d,", i);\r
+ pushe(heao, i);\r
}\r
- nx->next = NULL;\r
print_list(head);\r
printf("\n");\r
print_list(heao);\r