Page 1 of 1

C++ insert an element to the ith position in the linked list HINT: #include typedef int ElemType; typedef

Posted: Fri May 20, 2022 5:47 pm
by answerhappygod
C++ insert an element to the ith position in the linked
list

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;
}
}
C Insert An Element To The Ith Position In The Linked List Hint Include Iostream Typedef Int Elemtype Typedef 1
C Insert An Element To The Ith Position In The Linked List Hint Include Iostream Typedef Int Elemtype Typedef 1 (20.61 KiB) Viewed 30 times
Input i: where j is added j: element to be added For example: suppose list I contains: 0 1 2 after inserting 0 to the 1st position, I contains: 0 0 1 2 Output the elements of the list