C++ Lunked List - InsertHead HINT: #include typedef int ElemType; typedef struct LNode { ElemType data;
Posted: Fri May 20, 2022 5:45 pm
C++ Lunked List - InsertHead
HINT:
#include <iostream>
typedef int ElemType;
typedef struct LNode {
ElemType data;
struct LNode* next;
}LNode, *linkedList;
void showList(linkedList l) {
while (NULL != l) {
printf("%d\n", l->data);
l = l->next;
}
}
Description insert an element to the head of the linked list. Multiple elements can be inserted several times UNTIL a 0 is received. Input the elements to be inserted Output the elements just inserted.
HINT:
#include <iostream>
typedef int ElemType;
typedef struct LNode {
ElemType data;
struct LNode* next;
}LNode, *linkedList;
void showList(linkedList l) {
while (NULL != l) {
printf("%d\n", l->data);
l = l->next;
}
}
Description insert an element to the head of the linked list. Multiple elements can be inserted several times UNTIL a 0 is received. Input the elements to be inserted Output the elements just inserted.