1
0
mirror of https://gitlab.com/klmp200/LO27.git synced 2024-11-26 12:34:14 +00:00

Add true makefile + lists

This commit is contained in:
Antoine Bartuccio 2016-12-10 02:28:10 +01:00
parent a99b593863
commit 43f32a485a
8 changed files with 141 additions and 151 deletions

View File

@ -1,138 +0,0 @@
/***
--- CellElemFunc ---
---Created by : Naej Doree ---
***/
#include <stdio.h>
#include <stdlib.h>
#include <CellElement.h>
int main(int argc, char **argv){
cellElement * tree = NULL;
tree = CreateCellElem();
tree->colIndex = 1;
AddNextRow(tree);
tree->nextRow->colIndex = 2;
AddNextCol(tree);
tree->nextCol->colIndex = 3;
recursivePrint(tree);
removeNextRow(tree);
removeNextCol(tree);
recursivePrint(tree);
return 0;
}
cellElement * CreateCellElem(){
cellElement * elem = NULL;
elem = (cellElement*) malloc(sizeof(cellElement));
if (elem == NULL){
return NULL;
}
printf("---Created cellElement---\n");
elem->value = true;
elem->nextCol = NULL;
elem->nextRow = NULL;
return elem;
}
void freeCellElem(cellElement * elem){
free(elem);
elem = NULL;
}
int AddNextCol(cellElement* tree){
cellElement * elem = NULL;
elem = (cellElement*) malloc(sizeof(cellElement));
if (elem == NULL){
return -1;
}
printf("---insertNextCol---\n");
elem->value = true;
elem->nextCol = NULL;
elem->nextRow = NULL;
if (tree->nextCol == NULL){
tree->nextCol = elem;
}else{
return -2;
}
return 1;
}
int AddNextRow(cellElement* tree){
cellElement * elem = NULL;
elem = (cellElement*) malloc(sizeof(cellElement));
if (elem == NULL){
return -1;
}
printf("---insertNextRow---\n");
elem->value = true;
elem->nextRow = NULL;
elem->nextRow = NULL;
if (tree->nextRow == NULL){
tree->nextRow = elem;
}else{
return -2;
}
return 1;
}
void removeNextCol(cellElement* tree){
printf("---removeNextCol---\n");
if (tree->nextCol != NULL){
cellElement * elem = tree->nextCol;
free(elem);
elem = NULL;
tree->nextCol = NULL;
}
}
void removeNextRow(cellElement* tree){
printf("---removeNextRow---\n");
if (tree->nextRow != NULL){
cellElement* elem = tree->nextRow;
free(elem);
elem =NULL;
tree->nextRow = NULL;
}
}
void recursivePrint(cellElement * tree){
if (tree != NULL){
printf("Elem : x: %d y: %d \n",tree->colIndex,tree->rowIndex);
if (tree->nextCol != NULL){
recursivePrint(tree->nextCol);
}
if (tree->nextRow != NULL){
recursivePrint(tree->nextRow);
}
if (tree->nextCol == NULL && tree->nextCol == NULL){
printf("leaf\n");
}
}
}

Binary file not shown.

BIN
Exe

Binary file not shown.

View File

@ -1,14 +1,124 @@
/* /***
* @Author: klmp200 --- CellElemFunc ---
* @Date: 2016-12-10 01:32:50 ---Created by : Naej Doree ---
* @Last Modified by: klmp200 ***/
* @Last Modified time: 2016-12-10 04:29:48
*/
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <CellElement.h> #include <CellElement.h>
cellElement * CreateCellElem(){
cellElement * elem = NULL;
elem = (cellElement*) malloc(sizeof(cellElement));
if (elem == NULL){
return NULL;
}
printf("---Created cellElement---\n");
elem->value = true;
elem->nextCol = NULL;
elem->nextRow = NULL;
return elem;
}
void freeCellElem(cellElement * elem){
free(elem);
elem = NULL;
}
int AddNextCol(cellElement* tree){
cellElement * elem = NULL;
elem = (cellElement*) malloc(sizeof(cellElement));
if (elem == NULL){
return -1;
}
printf("---insertNextCol---\n");
elem->value = true;
elem->nextCol = NULL;
elem->nextRow = NULL;
if (tree->nextCol == NULL){
tree->nextCol = elem;
}else{
return -2;
}
return 1;
}
int AddNextRow(cellElement* tree){
cellElement * elem = NULL;
elem = (cellElement*) malloc(sizeof(cellElement));
if (elem == NULL){
return -1;
}
printf("---insertNextRow---\n");
elem->value = true;
elem->nextRow = NULL;
elem->nextRow = NULL;
if (tree->nextRow == NULL){
tree->nextRow = elem;
}else{
return -2;
}
return 1;
}
void removeNextCol(cellElement* tree){
printf("---removeNextCol---\n");
if (tree->nextCol != NULL){
cellElement * elem = tree->nextCol;
free(elem);
elem = NULL;
tree->nextCol = NULL;
}
}
void removeNextRow(cellElement* tree){
printf("---removeNextRow---\n");
if (tree->nextRow != NULL){
cellElement* elem = tree->nextRow;
free(elem);
elem =NULL;
tree->nextRow = NULL;
}
}
void recursivePrint(cellElement * tree){
if (tree != NULL){
printf("Elem : x: %d y: %d \n",tree->colIndex,tree->rowIndex);
if (tree->nextCol != NULL){
recursivePrint(tree->nextCol);
}
if (tree->nextRow != NULL){
recursivePrint(tree->nextRow);
}
if (tree->nextCol == NULL && tree->nextCol == NULL){
printf("leaf\n");
}
}
}
void FreeCellElement(cellElement* element) { void FreeCellElement(cellElement* element) {
if (element != NULL){ if (element != NULL){
free(element); free(element);

View File

@ -7,11 +7,15 @@
*@false : 0 *@false : 0
*/ */
typedef enum Bool{ typedef enum Bool{
<<<<<<< a99b5938634fe0e05047ed6418191cdbc8cb683a:LibList/CellElement.h
<<<<<<< 0996ce834deca07fbf19d0b5de5f3c8b568185e6:LibList/CellElement.h <<<<<<< 0996ce834deca07fbf19d0b5de5f3c8b568185e6:LibList/CellElement.h
======= =======
>>>>>>> tests et complètion des fx:CellElement.h >>>>>>> tests et complètion des fx:CellElement.h
=======
>>>>>>> Add true makefile + lists:LibList/CellElement.h
true = 1, true = 1,
false = 0 false = 0
@ -54,8 +58,12 @@ void FreeCellElement(cellElement* element);
======= =======
void removeNextCol(cellElement* list); void removeNextCol(cellElement* list);
void removeNextRow(cellElement* list); void removeNextRow(cellElement* list);
void recursivePrint(cellElement * tree); void recursivePrint(cellElement * tree);
>>>>>>> Added funcs about CellElement:CellElement.h >>>>>>> Added funcs about CellElement:CellElement.h
<<<<<<< a99b5938634fe0e05047ed6418191cdbc8cb683a:LibList/CellElement.h
=======
void FreeCellElement(cellElement* element);
>>>>>>> Add true makefile + lists:LibList/CellElement.h
#endif #endif

View File

@ -14,7 +14,6 @@ LIBSOURCEOFILE=$(LIBSOURCE:=.o)
#Generating the library binary #Generating the library binary
$(LIBTARGET): $(LIBSOURCEOFILE) $(LIBTARGET): $(LIBSOURCEOFILE)
@echo "\n Generating the library binary" @echo "\n Generating the library binary"
mkdir -p ../Libs
$(CC) $(CFLAGS) -shared $(LIBSOURCEOFILE) -o ../Libs/$(LIBTARGET) $(CC) $(CFLAGS) -shared $(LIBSOURCEOFILE) -o ../Libs/$(LIBTARGET)
#Generating object files #Generating object files

View File

@ -25,7 +25,6 @@ DEPENDENCENAMELIST=List
all: $(TARGET) all: $(TARGET)
#Generating the main.exe #Generating the main.exe
$(TARGET): $(SOURCEOFILE) $(DEPENDENCELIST) lib $(TARGET): $(SOURCEOFILE) $(DEPENDENCELIST) lib
@echo "\n Generating the " $(TARGET) " binary" @echo "\n Generating the " $(TARGET) " binary"

18
main.c
View File

@ -8,9 +8,21 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <CellElement.h>
int main(int argc, char **argv){
cellElement * tree = NULL;
tree = CreateCellElem();
tree->colIndex = 1;
AddNextRow(tree);
tree->nextRow->colIndex = 2;
AddNextCol(tree);
tree->nextCol->colIndex = 3;
recursivePrint(tree);
removeNextRow(tree);
removeNextCol(tree);
recursivePrint(tree);
int main(int argc, char *argv[])
{
printf("Hello World\n");
return 0; return 0;
} }