#include <stdio.h>
#include <stdlib.h>
typedef struct node {
int val;
struct node *next;
} Node;
Node *head = NULL;
void insHead(int x){
Node *p;
p
= (Node
*)malloc(sizeof(Node
)); p->val = x;
p->next = head; // 既存のリストを新しいノードの次に設定
head = p; // 新しいノードをリストの先頭に設定
}
void printL(){
Node *p = head;
while(p != NULL){
p = p->next;
}
}
int main(void){
insHead(1);
insHead(2);
insHead(2);
insHead(3);
printL();
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCnR5cGVkZWYgc3RydWN0IG5vZGUgewogICAgaW50IHZhbDsKICAgIHN0cnVjdCBub2RlICpuZXh0Owp9IE5vZGU7CgpOb2RlICpoZWFkID0gTlVMTDsKCnZvaWQgaW5zSGVhZChpbnQgeCl7CiAgICBOb2RlICpwOwogICAgcCA9IChOb2RlICopbWFsbG9jKHNpemVvZihOb2RlKSk7CiAgICBwLT52YWwgPSB4OwogICAgcC0+bmV4dCA9IGhlYWQ7ICAvLyDml6LlrZjjga7jg6rjgrnjg4jjgpLmlrDjgZfjgYTjg47jg7zjg4njga7mrKHjgavoqK3lrpoKICAgIGhlYWQgPSBwOyAgLy8g5paw44GX44GE44OO44O844OJ44KS44Oq44K544OI44Gu5YWI6aCt44Gr6Kit5a6aCn0KCnZvaWQgcHJpbnRMKCl7CiAgICBOb2RlICpwID0gaGVhZDsKICAgIHdoaWxlKHAgIT0gTlVMTCl7CiAgICAgICAgcHJpbnRmKCIlZCAiLCBwLT52YWwpOwogICAgICAgIHAgPSBwLT5uZXh0OwogICAgfQogICAgcHJpbnRmKCJcbiIpOwp9CgppbnQgbWFpbih2b2lkKXsKICAgIGluc0hlYWQoMSk7CiAgICBpbnNIZWFkKDIpOwogICAgaW5zSGVhZCgyKTsKICAgIGluc0hlYWQoMyk7CiAgICBwcmludEwoKTsKICAgIHJldHVybiAwOwp9Cg==