#include <stdio.h>
typedef struct _KZT {
int index;
char *name;
struct _KZT *prev;
struct _KZT *next;
} KZT;
int main()
{
int i;
KZT *p;
KZT d[] = {
{0, "miso" , NULL, &d[1]},
{1, "sio" , &d[0], &d[2]},
{2, "shoyu" , &d[1], &d[3]},
{3, "tonkotsu" , &d[2], NULL},
};
for (i = 0; i < sizeof(d) / sizeof(d[0]); i++) {
printf("[%d]:%d,%s\n", i
, d
[i
].
index, d
[i
].
name); }
p = &d[0];
do {
printf("%d,%s\n", p
->index
, p
->name
); p = p->next;
} while (p);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp0eXBlZGVmIHN0cnVjdCBfS1pUIHsKICAgIGludCBpbmRleDsKICAgIGNoYXIgKm5hbWU7CiAgICBzdHJ1Y3QgX0taVCAqcHJldjsKICAgIHN0cnVjdCBfS1pUICpuZXh0Owp9IEtaVDsKCmludCBtYWluKCkKewogICAgaW50IGk7CiAgICBLWlQgKnA7CiAgICBLWlQgZFtdID0gewogICAgICAgIHswLCAibWlzbyIgICAgICwgTlVMTCwgJmRbMV19LAogICAgICAgIHsxLCAic2lvIiAgICAgICwgJmRbMF0sICZkWzJdfSwKICAgICAgICB7MiwgInNob3l1IiAgICAsICZkWzFdLCAmZFszXX0sCiAgICAgICAgezMsICJ0b25rb3RzdSIgLCAmZFsyXSwgTlVMTH0sCiAgICB9OwoKICAgIGZvciAoaSA9IDA7IGkgPCBzaXplb2YoZCkgLyBzaXplb2YoZFswXSk7IGkrKykgewogICAgICAgIHByaW50ZigiWyVkXTolZCwlc1xuIiwgaSwgZFtpXS5pbmRleCwgZFtpXS5uYW1lKTsKICAgIH0KCiAgICBwID0gJmRbMF07CiAgICBkbyB7CiAgICAgICAgcHJpbnRmKCIlZCwlc1xuIiwgcC0+aW5kZXgsIHAtPm5hbWUpOwogICAgICAgIHAgPSBwLT5uZXh0OwogICAgfSB3aGlsZSAocCk7CiAgICByZXR1cm4gMDsKfQ==