#include <stdio.h>
#include <stdlib.h>
struct node{
int key, info;
struct node *next;
};
static struct node *head, *z;
void initialize()
{
head
= (struct node
*)malloc(sizeof *head
); z
= (struct node
*)malloc(sizeof *z
); head->next = z;
z->next = z;
z->key = -1;
}
void insert(int n, int info)
{
struct node *t, *x;
t = head;
while (t->next != z) {
t = t->next;
}
x
= (struct node
*)malloc (sizeof *x
); x->key = n;
x->next = t->next;
t->next = x;
x->info = info;
}
void show()
{
struct node *t = head;
while (t->next != z) {
t = t->next;
printf("%d\t%d\n", t
->key
, t
->info
); }
}
int main()
{
initialize();
int i, j;
printf("enter the number and info\n"); scanf("%d%d", &i
, &j
); // i is key and j is info insert(i, j); // passing arguments to insert function
show();
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCnN0cnVjdCBub2RlewoJaW50IGtleSwgaW5mbzsKCXN0cnVjdCBub2RlICpuZXh0Owp9OwoKc3RhdGljIHN0cnVjdCBub2RlICpoZWFkLCAqejsKCnZvaWQgaW5pdGlhbGl6ZSgpCnsKCWhlYWQgPSAoc3RydWN0IG5vZGUqKW1hbGxvYyhzaXplb2YgKmhlYWQpOwoJeiA9IChzdHJ1Y3Qgbm9kZSopbWFsbG9jKHNpemVvZiAqeik7CgloZWFkLT5uZXh0ID0gejsKCXotPm5leHQgPSB6OwoJei0+a2V5ID0gLTE7Cn0KCnZvaWQgaW5zZXJ0KGludCBuLCBpbnQgaW5mbykKewoJc3RydWN0IG5vZGUgKnQsICp4OwoKCXQgPSBoZWFkOwoKCXdoaWxlICh0LT5uZXh0ICE9IHopIHsKCQl0ID0gdC0+bmV4dDsKCX0KCgl4ID0gKHN0cnVjdCBub2RlICopbWFsbG9jIChzaXplb2YgKngpOwoJeC0+a2V5ID0gbjsKCXgtPm5leHQgPSB0LT5uZXh0OwoJdC0+bmV4dCA9IHg7Cgl4LT5pbmZvID0gaW5mbzsKfQoKdm9pZCBzaG93KCkKewoJc3RydWN0IG5vZGUgK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