1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2024-11-22 16:33:19 +00:00

Commencé matrices, l'exe ne veut plus se lancer pour des questions de build

This commit is contained in:
Naej 2016-12-13 15:55:42 +01:00
parent dba704e4e7
commit 3a91f0655a
5 changed files with 79 additions and 6 deletions

View File

@ -15,7 +15,7 @@ typedef enum Bool{
/*---cellElement---
*Pointer on a cell of the matrix
*A cell of the matrix
*
*@colIndex : index (int) of the column of this cell
*@rowIndex : index (int) of the row of this cell

View File

@ -7,7 +7,7 @@ INCLUDEDIR=-I/usr/include -I.
#Library variables
LIBTARGET=libAutomaton.so
LIBSOURCE=list CellElement
LIBSOURCE=list CellElement matrix
LIBSOURCECFILE=$(LIBSOURCE:=.c)
LIBSOURCEOFILE=$(LIBSOURCE:=.o)

41
LibAutomaton/Matrix.h Normal file
View File

@ -0,0 +1,41 @@
#ifndef MTRXGAUD_H
#define MTRXGAUD_H
#include <CellElement.h>
#include <list.h>
/*---Matrix---
*Abstract type that describe a boolean matrix
*
*@colCount : the number of columns of the matrix
*@rowIndex : the number of rows of the matrix
*
*@rows : pointer on the first row that contains a true value
*@cols : pointer on the first col that contains a true value
*
*/
typedef struct Matrix {
int colCount;
int rowCount;
List *cols;
List *rows;
}Matrix;
/*---applyRules---
*A function tha allows you to apply some rules n times on the matrix and returns it
*
*@matrix : A matrix on whitch you would apply the rules
*
*@Rules : Integer describing the rules
*
*@N : number of time the rules will be applied
*
*/
Matrix applyRules (Matrix matrix,int Rules, int N);
#endif

22
LibAutomaton/matrix.c Normal file
View File

@ -0,0 +1,22 @@
#include <stdio.h>
#include <stdlib.h>
#include <Matrix.h>
Matrix applyRules (Matrix matrix,int Rules, int N){
int pow = 2;
int i = 0;
if (Rules <= 0){
return matrix;
} else {
while (Rules%pow == 0 ){
pow*=2;
}
for (i=0;i<N;i++){
printf("Apply rule %d \n",Rules%pow);
/*Replace it by the implementation of the rules*/
}
applyRules(matrix,Rules - Rules%pow,N);
}
return matrix;
}

18
main.c
View File

@ -8,12 +8,22 @@
#include <stdio.h>
#include <stdlib.h>
#include <CellElement.h>
#include <list.h>
#include <Matrix.h>
int main(int argc, char **argv){
Matrix matrix;
int Rule = 170;
int N = 1;
applyRules (matrix,Rule,N);
/*
Matrix matrix;
cellElement * tree = NULL;
List * cols = NULL;
List * rows = NULL;
cols = CreateList();
rows = CreateList();
tree = CreateCellElem();
SetPositionIndex(tree,1,1);
@ -33,7 +43,7 @@ int main(int argc, char **argv){
removeNextCol(tree);
recursivePrint(tree);
*/
return 0;
}