Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 57fb482c0a | |||
| 3c4e3c952f | |||
| c1a3e1601e | |||
| 28aa63db4d | |||
| 29706fe8be | |||
| a4e444f43a |
BIN
System2/create_ps/a.out
Executable file
BIN
System2/create_ps/a.out
Executable file
Binary file not shown.
33
System2/create_ps/main.c
Normal file
33
System2/create_ps/main.c
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
pid_t fpid;
|
||||||
|
|
||||||
|
fpid = fork();
|
||||||
|
// create child process
|
||||||
|
if (fpid == -1)
|
||||||
|
{
|
||||||
|
perror("perror in fork!");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fpid == 0)
|
||||||
|
{
|
||||||
|
printf("I am the child process, my process id is %d\n", getpid());
|
||||||
|
sleep(1);
|
||||||
|
printf("child process DONE\n");
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("I am the parent process, my process id is %d\n", getpid());
|
||||||
|
wait(NULL);
|
||||||
|
printf("parent process DONE\n");
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
}
|
||||||
BIN
TP2/tableau/bubbleSort.o
Executable file
BIN
TP2/tableau/bubbleSort.o
Executable file
Binary file not shown.
BIN
TP2/tableau/quickSort.o
Executable file
BIN
TP2/tableau/quickSort.o
Executable file
Binary file not shown.
253
TP3/List/BlockList.c
Normal file
253
TP3/List/BlockList.c
Normal file
@@ -0,0 +1,253 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "BlockList.h"
|
||||||
|
#define BLOCK_SIZE 5
|
||||||
|
|
||||||
|
struct SList
|
||||||
|
{
|
||||||
|
SCell *first;
|
||||||
|
SCell *last;
|
||||||
|
SBlock *block;
|
||||||
|
SCell *recycle;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SCell
|
||||||
|
{
|
||||||
|
int data;
|
||||||
|
SCell *next;
|
||||||
|
SCell *prev;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SBlock
|
||||||
|
{
|
||||||
|
SCell tab[BLOCK_SIZE];
|
||||||
|
SBlock *bnext;
|
||||||
|
};
|
||||||
|
|
||||||
|
SList *CreateList()
|
||||||
|
{
|
||||||
|
SList *list;
|
||||||
|
list->block = CreateBlock();
|
||||||
|
list->first = NULL;
|
||||||
|
list->last = NULL;
|
||||||
|
list->recycle = NULL;
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
SBlock *CreateBlock()
|
||||||
|
{
|
||||||
|
SBlock *block = (SBlock *)malloc(sizeof(SBlock));
|
||||||
|
block->bnext = NULL;
|
||||||
|
for (int i; i < BLOCK_SIZE; i++)
|
||||||
|
{
|
||||||
|
block->tab[i].data = NULL;
|
||||||
|
block->tab[i].prev = NULL;
|
||||||
|
block->tab[i].next = NULL;
|
||||||
|
}
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeleteList(SList *list)
|
||||||
|
{
|
||||||
|
SCell *cell = GetFirstElement(list);
|
||||||
|
while (cell != NULL)
|
||||||
|
{
|
||||||
|
SCell *next = GetNextElement(cell);
|
||||||
|
DeleteCell(list, cell);
|
||||||
|
cell = next;
|
||||||
|
}
|
||||||
|
free(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
SCell *GetCellFromBlock(SList *list)
|
||||||
|
{
|
||||||
|
SCell *pcell;
|
||||||
|
while (!(pcell = _GetCellFromBlock(list->block)))
|
||||||
|
{
|
||||||
|
AddBlock(list->block);
|
||||||
|
}
|
||||||
|
return pcell;
|
||||||
|
}
|
||||||
|
|
||||||
|
SBlock *AddBlock(SBlock *blist)
|
||||||
|
{
|
||||||
|
SBlock *pblock = CreateBlock();
|
||||||
|
while (blist->bnext != NULL)
|
||||||
|
{
|
||||||
|
blist = blist->bnext;
|
||||||
|
}
|
||||||
|
blist->bnext = pblock;
|
||||||
|
return pblock;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCell *_GetCellFromBlock(SBlock *bList)
|
||||||
|
{
|
||||||
|
while (bList != NULL)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < BLOCK_SIZE; i++)
|
||||||
|
{
|
||||||
|
if ((bList->tab)[i].data == NULL)
|
||||||
|
{
|
||||||
|
return &(bList->tab)[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bList = bList->bnext;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCell *AddElementBegin(SList *list, int data)
|
||||||
|
{
|
||||||
|
SCell *cell = GetCellFromBlock(list);
|
||||||
|
cell->data = data;
|
||||||
|
cell->next = list->first;
|
||||||
|
cell->prev = NULL;
|
||||||
|
if (list->first != NULL)
|
||||||
|
{
|
||||||
|
list->first->prev = cell;
|
||||||
|
}
|
||||||
|
list->first = cell;
|
||||||
|
if (list->last == NULL)
|
||||||
|
{
|
||||||
|
list->last = cell;
|
||||||
|
}
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCell *AddElementEnd(SList *list, int data)
|
||||||
|
{
|
||||||
|
SCell *cell = GetCellFromBlock(list);
|
||||||
|
cell->data = data;
|
||||||
|
cell->next = NULL;
|
||||||
|
cell->prev = list->last;
|
||||||
|
if (list->last != NULL)
|
||||||
|
{
|
||||||
|
list->last->next = cell;
|
||||||
|
}
|
||||||
|
list->last = cell;
|
||||||
|
if (list->first == NULL)
|
||||||
|
{
|
||||||
|
list->first = cell;
|
||||||
|
}
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCell *AddElementAfter(SList *list, SCell *cell, int data)
|
||||||
|
{
|
||||||
|
if (cell == NULL)
|
||||||
|
{
|
||||||
|
return AddElementBegin(list, data);
|
||||||
|
}
|
||||||
|
else if (cell == list->last)
|
||||||
|
{
|
||||||
|
return AddElementEnd(list, data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SCell *newCell = GetCellFromBlock(list);
|
||||||
|
newCell->data = data;
|
||||||
|
newCell->next = cell->next;
|
||||||
|
newCell->prev = cell;
|
||||||
|
cell->next->prev = newCell;
|
||||||
|
cell->next = newCell;
|
||||||
|
return newCell;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SCell *RecycleCell(SCell *head, SCell *cell)
|
||||||
|
{
|
||||||
|
cell->next = NULL;
|
||||||
|
SCell *recycle = head;
|
||||||
|
if (recycle == NULL)
|
||||||
|
{
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
while (recycle->next != NULL)
|
||||||
|
{
|
||||||
|
recycle = recycle->next;
|
||||||
|
}
|
||||||
|
recycle->next = cell;
|
||||||
|
return head;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeleteCell(SList *list, SCell *cell)
|
||||||
|
{
|
||||||
|
if (cell == list->first)
|
||||||
|
{
|
||||||
|
list->first = cell->next;
|
||||||
|
}
|
||||||
|
if (cell == list->last)
|
||||||
|
{
|
||||||
|
list->last = cell->prev;
|
||||||
|
}
|
||||||
|
if (cell->prev != NULL)
|
||||||
|
{
|
||||||
|
cell->prev->next = cell->next;
|
||||||
|
}
|
||||||
|
if (cell->next != NULL)
|
||||||
|
{
|
||||||
|
cell->next->prev = cell->prev;
|
||||||
|
}
|
||||||
|
list->recycle = RecycleCell(list->recycle, cell);
|
||||||
|
}
|
||||||
|
|
||||||
|
SCell *GetFirstElement(SList *list)
|
||||||
|
{
|
||||||
|
return list->first;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCell *GetLastElement(SList *list)
|
||||||
|
{
|
||||||
|
return list->last;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCell *GetNextElement(SCell *cell)
|
||||||
|
{
|
||||||
|
return cell->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCell *GetPrevElement(SCell *cell)
|
||||||
|
{
|
||||||
|
return cell->prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetData(SCell *cell)
|
||||||
|
{
|
||||||
|
return cell->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintBlockList(SList *list)
|
||||||
|
{
|
||||||
|
printf("Block: ");
|
||||||
|
SBlock *pBlock = list->block;
|
||||||
|
while (pBlock != NULL)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < BLOCK_SIZE; i++)
|
||||||
|
{
|
||||||
|
if (pBlock->tab[i].data != NULL)
|
||||||
|
{
|
||||||
|
printf(" [%d] ", pBlock->tab[i].data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf(" | NULL | ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("-->");
|
||||||
|
pBlock = pBlock->bnext;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintRecycleList(SList *list)
|
||||||
|
{
|
||||||
|
printf("Recycle: ");
|
||||||
|
SCell *pCell = list->recycle;
|
||||||
|
while (pCell != NULL)
|
||||||
|
{
|
||||||
|
printf("[%d] -> ", pCell->data);
|
||||||
|
pCell = pCell->next;
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
}
|
||||||
28
TP3/List/BlockList.h
Normal file
28
TP3/List/BlockList.h
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#ifndef _LISTE_H
|
||||||
|
#define _LISTE_H
|
||||||
|
|
||||||
|
typedef int Data;
|
||||||
|
typedef struct SCell SCell;
|
||||||
|
typedef struct SList SList;
|
||||||
|
typedef struct SBlock SBlock;
|
||||||
|
|
||||||
|
SList *CreateList();
|
||||||
|
SBlock *CreateBlock();
|
||||||
|
void DeleteList(SList *list);
|
||||||
|
SCell *_GetCellFromBlock(SBlock *bList);
|
||||||
|
SBlock *AddBlock(SBlock *blist);
|
||||||
|
SCell *AddElementBegin(SList *list, Data elem);
|
||||||
|
SCell *AddElementEnd(SList *list, Data elem);
|
||||||
|
SCell *AddElementAfter(SList *list, SCell *cell, Data elem);
|
||||||
|
void DeleteCell(SList *list, SCell *cell);
|
||||||
|
void PrintRecycleList(SList *list);
|
||||||
|
SCell* RecycleCell(SCell *, SCell *cell);
|
||||||
|
|
||||||
|
SCell *GetFirstElement(SList *list);
|
||||||
|
SCell *GetLastElement(SList *list);
|
||||||
|
SCell *GetPrevElement(SCell *cell);
|
||||||
|
SCell *GetNextElement(SCell *cell);
|
||||||
|
Data GetData(SCell *cell);
|
||||||
|
void PrintBlockList(SList *list);
|
||||||
|
|
||||||
|
#endif
|
||||||
91
TP3/List/BlockMain.c
Normal file
91
TP3/List/BlockMain.c
Normal file
@@ -0,0 +1,91 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "BlockList.h"
|
||||||
|
|
||||||
|
void PrintList(SList *list);
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
SList *list;
|
||||||
|
SCell *cell1, *cell2;
|
||||||
|
|
||||||
|
list = CreateList();
|
||||||
|
AddElementEnd(list, 1);
|
||||||
|
AddElementEnd(list, 2);
|
||||||
|
AddElementEnd(list, 3);
|
||||||
|
AddElementEnd(list, 4);
|
||||||
|
cell1 = AddElementEnd(list, 5);
|
||||||
|
AddElementEnd(list, 6);
|
||||||
|
AddElementEnd(list, 7);
|
||||||
|
AddElementEnd(list, 8);
|
||||||
|
cell2 = AddElementEnd(list, 9);
|
||||||
|
|
||||||
|
PrintList(list);
|
||||||
|
PrintBlockList(list);
|
||||||
|
PrintRecycleList(list);
|
||||||
|
DeleteCell(list, cell1);
|
||||||
|
PrintList(list);
|
||||||
|
PrintBlockList(list);
|
||||||
|
PrintRecycleList(list);
|
||||||
|
DeleteCell(list, cell2);
|
||||||
|
PrintList(list);
|
||||||
|
PrintBlockList(list);
|
||||||
|
PrintRecycleList(list);
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
// printf("Add 5, 3, 1\n");
|
||||||
|
// AddElementEnd(list, 5);
|
||||||
|
// cell = AddElementEnd(list, 3);
|
||||||
|
// AddElementEnd(list, 1);
|
||||||
|
// PrintList(list);
|
||||||
|
// PrintBlockList(list);
|
||||||
|
// printf("\n");
|
||||||
|
|
||||||
|
// printf("Add 6, 8\n");
|
||||||
|
// AddElementEnd(list, 6);
|
||||||
|
// AddElementEnd(list, 8);
|
||||||
|
// PrintList(list);
|
||||||
|
// PrintBlockList(list);
|
||||||
|
// printf("\n");
|
||||||
|
|
||||||
|
// printf("Add 4\n");
|
||||||
|
// AddElementAfter(list, cell, 4);
|
||||||
|
// PrintList(list);
|
||||||
|
// PrintBlockList(list);
|
||||||
|
// printf("\n");
|
||||||
|
|
||||||
|
// printf("Add 2\n");
|
||||||
|
// AddElementAfter(list, GetFirstElement(list), 2);
|
||||||
|
// PrintList(list);
|
||||||
|
// printf("\n");
|
||||||
|
|
||||||
|
// printf("Delete 3\n");
|
||||||
|
// DeleteCell(list, cell);
|
||||||
|
// PrintList(list);
|
||||||
|
// printf("\n");
|
||||||
|
|
||||||
|
// printf("Add 7\n");
|
||||||
|
// AddElementAfter(list, GetPrevElement(GetLastElement(list)), 7);
|
||||||
|
// PrintList(list);
|
||||||
|
// printf("\n");
|
||||||
|
|
||||||
|
// DeleteList(list);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintList(SList *list)
|
||||||
|
{
|
||||||
|
printf("List: ");
|
||||||
|
if (list)
|
||||||
|
{
|
||||||
|
SCell *cell = GetFirstElement(list);
|
||||||
|
while (cell != NULL)
|
||||||
|
{
|
||||||
|
printf("[%d] -> ", GetData(cell));
|
||||||
|
cell = GetNextElement(cell);
|
||||||
|
}
|
||||||
|
printf("NULL\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
140
TP3/List/Liste.c
Normal file
140
TP3/List/Liste.c
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "Liste.h"
|
||||||
|
|
||||||
|
struct SList
|
||||||
|
{
|
||||||
|
SCell *first;
|
||||||
|
SCell *last;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SCell
|
||||||
|
{
|
||||||
|
int data;
|
||||||
|
SCell *next;
|
||||||
|
SCell *prev;
|
||||||
|
};
|
||||||
|
|
||||||
|
SList *CreateList()
|
||||||
|
{
|
||||||
|
SList *list = (SList *)malloc(sizeof(SList));
|
||||||
|
list->first = NULL;
|
||||||
|
list->last = NULL;
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeleteList(SList *list)
|
||||||
|
{
|
||||||
|
SCell *cell = GetFirstElement(list);
|
||||||
|
while (cell != NULL)
|
||||||
|
{
|
||||||
|
SCell *next = GetNextElement(cell);
|
||||||
|
DeleteCell(list, cell);
|
||||||
|
cell = next;
|
||||||
|
}
|
||||||
|
free(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
SCell *AddElementBegin(SList *list, int data)
|
||||||
|
{
|
||||||
|
SCell *cell = (SCell *)malloc(sizeof(SCell));
|
||||||
|
cell->data = data;
|
||||||
|
cell->next = list->first;
|
||||||
|
cell->prev = NULL;
|
||||||
|
if (list->first != NULL)
|
||||||
|
{
|
||||||
|
list->first->prev = cell;
|
||||||
|
}
|
||||||
|
list->first = cell;
|
||||||
|
if (list->last == NULL)
|
||||||
|
{
|
||||||
|
list->last = cell;
|
||||||
|
}
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCell *AddElementEnd(SList *list, int data)
|
||||||
|
{
|
||||||
|
SCell *cell = (SCell *)malloc(sizeof(SCell));
|
||||||
|
cell->data = data;
|
||||||
|
cell->next = NULL;
|
||||||
|
cell->prev = list->last;
|
||||||
|
if (list->last != NULL)
|
||||||
|
{
|
||||||
|
list->last->next = cell;
|
||||||
|
}
|
||||||
|
list->last = cell;
|
||||||
|
if (list->first == NULL)
|
||||||
|
{
|
||||||
|
list->first = cell;
|
||||||
|
}
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCell *AddElementAfter(SList *list, SCell *cell, int data)
|
||||||
|
{
|
||||||
|
if (cell == NULL)
|
||||||
|
{
|
||||||
|
return AddElementBegin(list, data);
|
||||||
|
}
|
||||||
|
else if (cell == list->last)
|
||||||
|
{
|
||||||
|
return AddElementEnd(list, data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SCell *newCell = (SCell *)malloc(sizeof(SCell));
|
||||||
|
newCell->data = data;
|
||||||
|
newCell->next = cell->next;
|
||||||
|
newCell->prev = cell;
|
||||||
|
cell->next->prev = newCell;
|
||||||
|
cell->next = newCell;
|
||||||
|
return newCell;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeleteCell(SList *list, SCell *cell)
|
||||||
|
{
|
||||||
|
if (cell == list->first)
|
||||||
|
{
|
||||||
|
list->first = cell->next;
|
||||||
|
}
|
||||||
|
if (cell == list->last)
|
||||||
|
{
|
||||||
|
list->last = cell->prev;
|
||||||
|
}
|
||||||
|
if (cell->prev != NULL)
|
||||||
|
{
|
||||||
|
cell->prev->next = cell->next;
|
||||||
|
}
|
||||||
|
if (cell->next != NULL)
|
||||||
|
{
|
||||||
|
cell->next->prev = cell->prev;
|
||||||
|
}
|
||||||
|
free(cell);
|
||||||
|
}
|
||||||
|
|
||||||
|
SCell *GetFirstElement(SList *list)
|
||||||
|
{
|
||||||
|
return list->first;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCell *GetLastElement(SList *list)
|
||||||
|
{
|
||||||
|
return list->last;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCell *GetNextElement(SCell *cell)
|
||||||
|
{
|
||||||
|
return cell->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
SCell *GetPrevElement(SCell *cell)
|
||||||
|
{
|
||||||
|
return cell->prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetData(SCell *cell)
|
||||||
|
{
|
||||||
|
return cell->data;
|
||||||
|
}
|
||||||
22
TP3/List/Liste.h
Normal file
22
TP3/List/Liste.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef _LISTE_H
|
||||||
|
#define _LISTE_H
|
||||||
|
|
||||||
|
typedef int Data;
|
||||||
|
typedef struct SCell SCell;
|
||||||
|
typedef struct SList SList;
|
||||||
|
|
||||||
|
SList *CreateList();
|
||||||
|
void DeleteList(SList *list);
|
||||||
|
|
||||||
|
SCell *AddElementBegin(SList *list, Data elem);
|
||||||
|
SCell *AddElementEnd(SList *list, Data elem);
|
||||||
|
SCell *AddElementAfter(SList *list, SCell *cell, Data elem);
|
||||||
|
void DeleteCell(SList *list, SCell *cell);
|
||||||
|
|
||||||
|
SCell *GetFirstElement(SList *list);
|
||||||
|
SCell *GetLastElement(SList *list);
|
||||||
|
SCell *GetPrevElement(SCell *cell);
|
||||||
|
SCell *GetNextElement(SCell *cell);
|
||||||
|
Data GetData(SCell *cell);
|
||||||
|
|
||||||
|
#endif
|
||||||
BIN
TP3/List/a.out
Executable file
BIN
TP3/List/a.out
Executable file
Binary file not shown.
64
TP3/List/main.c
Normal file
64
TP3/List/main.c
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "Liste.h"
|
||||||
|
|
||||||
|
void PrintList(SList *list);
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
SList *list;
|
||||||
|
SCell *cell;
|
||||||
|
|
||||||
|
list = CreateList();
|
||||||
|
|
||||||
|
printf("Add 5, 3, 1\n");
|
||||||
|
AddElementBegin(list, 5);
|
||||||
|
cell = AddElementBegin(list, 3);
|
||||||
|
AddElementBegin(list, 1);
|
||||||
|
PrintList(list);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
printf("Add 6, 8\n");
|
||||||
|
AddElementEnd(list, 6);
|
||||||
|
AddElementEnd(list, 8);
|
||||||
|
PrintList(list);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
printf("Add 4\n");
|
||||||
|
AddElementAfter(list, cell, 4);
|
||||||
|
PrintList(list);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
printf("Add 2\n");
|
||||||
|
AddElementAfter(list, GetFirstElement(list), 2);
|
||||||
|
PrintList(list);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
printf("Delete 3\n");
|
||||||
|
DeleteCell(list, cell);
|
||||||
|
PrintList(list);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
printf("Add 7\n");
|
||||||
|
AddElementAfter(list, GetPrevElement(GetLastElement(list)), 7);
|
||||||
|
PrintList(list);
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
DeleteList(list);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintList(SList *list)
|
||||||
|
{
|
||||||
|
if (list)
|
||||||
|
{
|
||||||
|
SCell *cell = GetFirstElement(list);
|
||||||
|
while (cell != NULL)
|
||||||
|
{
|
||||||
|
printf("[%d] -> ", GetData(cell));
|
||||||
|
cell = GetNextElement(cell);
|
||||||
|
}
|
||||||
|
printf("NULL\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
7
langage_C.code-workspace
Normal file
7
langage_C.code-workspace
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user