Posted on 2012-08-19 20:37
hoshelly 阅读(126)
评论(0) 编辑 收藏 引用 所属分类:
DS && Algorithm
#include<stdio.h>
#include<stdlib.h>
typedef struct node *link;
struct node
{ int v; link next; };
link NEW(int v, link next)
{
link x = (link)malloc(sizeof(node));
x->v = v; x->next = next;
return x;
}
int main()
{
int i,j;
link adj[7];
for(i=0;i<7;i++)
adj[i] = NULL;
while (scanf("%d%d",&i,&j) == 2)
{
adj[j] = NEW(i,adj[j]);
adj[i] = NEW(j,adj[i]);
}
return 0;
}