Liste fini
This commit is contained in:
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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user