This program is supposed to show the adjacency lists that are built given the input pairs::
0-2, 1-4, 2-5, 3-6, 0-4, 6-0, and 1-3
I am having trouble with the syntax of my code. Could someone please help?
#include <iostream>
using namespace::std;
int V;
struct node
{ int v; node* next;
node(int x, node* t)
{v=x; next = t;}
};
typedef node *link;
int main()
{ int i, j; link adj[V];
for (i=0; i<V; i++) adj[i] = 0;
while (cin >> i >> j)
{
adj[j] = new node(i, adj[j]);
adj[i] = new node(j, adj[i]);
}
}
Thx!!!