#include<stdio.h>
//#include<string.h>
struct data{
char key;
struct data *next;
};
int main()
{
struct data *top;
top
= (struct data
*)malloc(sizeof(struct data
)); if(top
== NULL
){printf("メモりが確保できませんでした。\n"); return 1; } top->key = 'a';
top
->next
= (struct data
*)malloc(sizeof(struct data
)); if(top
->next
== NULL
){printf("メモりが確保できませんでした。\n"); return 1; }
// top = top->next;
top->next->key = 'b';
top
->next
->next
= (struct data
*)malloc(sizeof(struct data
)); if(top
->next
->next
== NULL
){printf("メモりが確保できませんでした。\n"); return 1; }
// top = top->next->next;
top->next->next->key = 'c';
top->next->next->next = NULL;
printf("%c\n", top
->next
->key
); printf("%c\n", top
->next
->next
->key
);
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KLy8jaW5jbHVkZTxzdHJpbmcuaD4KCnN0cnVjdCBkYXRhewogIGNoYXIga2V5OwogIHN0cnVjdCBkYXRhICpuZXh0Owp9OwogCiAgaW50IG1haW4oKQogIHsKIAogICAgc3RydWN0IGRhdGEgKnRvcDsKIAogICAgdG9wID0gKHN0cnVjdCBkYXRhKiltYWxsb2Moc2l6ZW9mKHN0cnVjdCBkYXRhKSk7CiAgICBpZih0b3AgPT0gTlVMTCl7cHJpbnRmKCLjg6Hjg6LjgorjgYznorrkv53jgafjgY3jgb7jgZvjgpPjgafjgZfjgZ/jgIJcbiIpOyByZXR1cm4gMTsgICAgIH0KICAgIHRvcC0+a2V5ID0gJ2EnOwogICAgdG9wLT5uZXh0ID0gKHN0cnVjdCBkYXRhKiltYWxsb2Moc2l6ZW9mKHN0cnVjdCBkYXRhKSk7CiAgICBpZih0b3AtPm5leHQgPT0gTlVMTCl7cHJpbnRmKCLjg6Hjg6LjgorjgYznorrkv53jgafjgY3jgb7jgZvjgpPjgafjgZfjgZ/jgIJcbiIpOyByZXR1cm4gMTsgICAgICAgIH0KIAogCi8vICAgIHRvcCA9IHRvcC0+bmV4dDsKICAgIHRvcC0+bmV4dC0+a2V5ID0gJ2InOwogICAgdG9wLT5uZXh0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