#include <stdlib.h>
#include <stdio.h>
#include <math.h>

#include "hybrid.h"

int main(void)
{
	int i;
/*  now the phantom matrix */
		printf("populating the phantom array!!\n");
			for (i=1;i!=5;i=i+1)
			{
				creer();
			}

		printf("give those ghost some random data !!!\n");
			ici = head;
			i = 1;
			while (ici->next != NULL)
			{
				ici->une = i;	 i=i+1;
				ici->col = 1+rand()%4;
				ici->row = 1+rand()%4;
				ici = ici->next;
			}
		printf("see what happened !!!!\n");
			ici = head;
			while (ici->next != NULL)
			{
				printf("ici->col = %d | ici->row = %d | ici->une = %d\n",ici->col,ici->row,ici->une);
				ici = ici->next;
			}
		printf("\n");

		printf("let try to put them in a matrix\n");
			ici = head;
			while (ici->next != NULL)
			{
				matrix[ici->col][ici->row] = ici;
				ici = ici->next;
			}
		printf("and see if it worked \n");
			int m,n;
			for (m=1;m!=6;m=m+1)
			{	for (n=1;n!=6;n=n+1)
				{
					if (matrix[n][m] == 0)
					{	
						printf(" 0 |");
					} else {
						printf(" %d |",matrix[n][m]->une);
					}
				}
				printf("\n");
			}
		
		printf("see how its possible to destroy the matrix[2][4] \n");
			detruire(matrix[2][4]);
			matrix[2][4] = NULL;
		printf("see what happened !!!!\n");
			ici = head;
			while (ici->next != NULL)
			{
				printf("ici->col = %d | ici->row = %d | ici->une = %d\n",ici->col,ici->row,ici->une);
				ici = ici->next;
			}
			for (m=1;m!=6;m=m+1)
			{	for (n=1;n!=6;n=n+1)
				{
					if (matrix[n][m] == 0)
					{	
						printf(" 0 |");
					} else {
						printf(" %d |",matrix[n][m]->une);
					}
				}
				printf("\n");
			}

		printf("end of transmition\n");
	return 0;
}
