/* * プログラミング演習 第 9 回 * [例題 2] * (C) 2006 Hirohisa AMAN */ #include /* 構造体 vnode の宣言 */ struct vnode { int x; int y; struct vnode* next; }; int main(void){ struct vnode sample[3]; struct vnode* head; struct vnode* p; /* 各データを格納 */ sample[0].x = 2; sample[0].y = 3; sample[1].x = 1; sample[1].y = -1; sample[2].x = 7; sample[2].y = 2; /* 各ノードを連結 */ head = &sample[0]; sample[0].next = &sample[1]; sample[1].next = &sample[2]; sample[2].next = head; /* リストの内容を表示 */ p = head; while ( p != NULL ){ printf("(%d,%d)\n", p->x, p->y); p = p->next; } return 0; }