В моей программе я использую связанный список, я хотел бы иметь возможность go вернуться к началу его работы, когда захочу, и добавить элемент в его конец.
void append(struct Node** head, int num)
{
struct Node *current = **(&head);
static struct Node *last = NULL;
static struct Node *start = NULL;
if (*head != NULL)
{
current = *(&last);
current->next = new Node;
current->next->data = num;
current->next->next = NULL;
current->next->start = start;
last = current->next;
return;
}
struct Node *temp = new Node;
temp->data = num;
temp->next = *head;
*head = temp;
start = *head;
last = *head;
temp->start = start;
}
Я сделал эту функцию сам, так что я представляю, что она может быть улучшена до исполнения. Пожалуйста, помогите:)
Заранее спасибо!