Untitled
Anonymous
plain_text
04/28/2023 9:53 AM
1.2 KB
14
Indexable
#include <stdio.h>
#include <stdlib.h>
struct node {
int data;
struct node *link;
};
int main() {
struct node *head = (struct node *)malloc(sizeof(struct node));
head->data = 3;
head->link = NULL;
struct node *current = (struct node *)malloc(sizeof(struct node));
current->data = 4;
current->link = NULL;
head->link = current;
current = (struct node *)malloc(sizeof(struct node));
current->data = 2;
current->link = NULL;
head->link->link = current;
current = (struct node *)malloc(sizeof(struct node));
current->data = 8;
current->link = NULL;
head->link->link->link = current;
current = (struct node *)malloc(sizeof(struct node));
current->data = 8;
current->link = NULL;
head->link->link->link->link = current;
printf("%d", head->data);
return 0;
}
Editor is loading...