#include #include #include struct node { double key; char *val; struct node *next; }; double access(double x, struct node *p); void insert(double d, char *b, struct node **p); void print(struct node *p); int main() { struct node *ptr = NULL; insert(2.5, "Tomek", &ptr); print(ptr); getchar(); return 0; } void insert(double d, char *b, struct node **p) { struct node *ntr = (struct node *)malloc(sizeof(struct node)); ntr->val = (char *)malloc(strlen(b)+1); ntr->key = d; strcpy(ntr->val, b); ntr->next = *p; *p = ntr; } void print(struct node *p) { if (p == NULL) return; printf("%d %s \n", p->key, p->val); p = p->next; } double access(double x, struct node **p) { struct node *ntr = (struct node *)malloc(sizeof(struct node)); while(*p) { if ((*p)->key == x) return x; else { ntr->key = 0; ntr->next = *p; *p = ntr; } *p = (*p)->next; } return 0; }