[ create a new paste ] login | about

Link: http://codepad.org/QZ6bpbsT    [ raw code | output | fork ]

C++, pasted on Nov 13:
#include <stdio.h>

typedef struct 
{
	int n1;
	int n2;
} NODES;

#define N 4
#define __countof(p) sizeof(p)/sizeof(p[0]) \

int main(int argc, char* argv[])
{
	static NODES pNodes[] = { { 1, 2 },
							  { 0, 1 },
							  { 1, 3 },
							  { 3, 2 } };

	int A[N][N] = { { 0 } };
	for (int index = 0; index != __countof(pNodes); index++)
		A[pNodes[index].n1][pNodes[index].n2] = 1;

	for (int t1 = 0; t1 < N; t1++)
	{
		for (int t2 = 0; t2 < N; t2++)
			printf("%d ",A[t1][t2]);

		printf("\n");
	}

	return 0;
}


Output:
1
2
3
4
0 1 0 0 
0 0 1 1 
0 0 0 0 
0 0 1 0 


Create a new paste based on this one


Comments: