diff --git a/myTP/TP12/exo1.c b/myTP/TP12/exo1.c index af97c86d6c4a23ee9430e121d9109e83cf3ffffd..c7119492dc50111bc5bbb612241d7ddd06933adf 100644 --- a/myTP/TP12/exo1.c +++ b/myTP/TP12/exo1.c @@ -87,11 +87,7 @@ void dir_print(directory_t *dir,int n){ person_t t = dir->content[n]; printf("[%d] ",n); person_print(t); - } - - - } diff --git a/myTP/TP13/exo1 b/myTP/TP13/exo1 old mode 100644 new mode 100755 index 6ed247a3f99a740a556b9668eca78555510f9659..76d3522c93979b4b5ddde867ec6e67ccaf724810 Binary files a/myTP/TP13/exo1 and b/myTP/TP13/exo1 differ diff --git a/myTP/TP13/exo1.c b/myTP/TP13/exo1.c index 762ef751095f2606161b8dc41f7c4b60577ca1cf..b4c8fc07ec72044b17731389345cade0f4024b4c 100644 --- a/myTP/TP13/exo1.c +++ b/myTP/TP13/exo1.c @@ -9,24 +9,22 @@ void reverse(char [], int, int); int count(char* str, char c); int main() { - char str1[20]= "salut"; - int size; + char test_char = 'a'; + char* str = "Salut les amis"; - char* str = "Salut les amis\n"; + printf(" le nombre de charactère: '%c' dans %s est : %d",test_char,str,count(str,test_char)); - size = strlen(str1); - reverse(str1, 0, size - 1); - + //reverse(str1, 0, size - 1); + printf("\n"); reverse_print(str); - printf("Number: %d\n",count(str,'a')); - - printf("The string after reversing is: %s\n", str1); + return 0; } void reverse_print(char* str){ + if(*str){ reverse_print(str+1); @@ -40,18 +38,6 @@ int count(char* str, char c){ return count(str+1,c)+(*str==c); } - + return 0; } - -void reverse(char str1[], int index, int size) -{ - char temp; - temp = str1[index]; - str1[index] = str1[size - index]; - str1[size - index] = temp; - if (index == size / 2) - { - return; - } - reverse(str1, index + 1, size); -} \ No newline at end of file + \ No newline at end of file diff --git a/myTP/TP13/exo2.c b/myTP/TP13/exo2.c new file mode 100644 index 0000000000000000000000000000000000000000..64316b8bfe61ff075779780d517ebaaab1f299f6 --- /dev/null +++ b/myTP/TP13/exo2.c @@ -0,0 +1,39 @@ +#include <stdio.h> +#include <string.h> + + +typedef enum{WALL, PATH, START, END} maze_part_t; + +typedef struct{ +maze_part_t** data; +int n; +}maze_t; + + +// Affiche un labyrinthe dans le console +void maze_print(maze_t maze); +// Cette fonction alloue la mémoire pour un labyrinthe +// Initialise toutes les cases à WALL +maze_t maze_alloc(int n); +// Libère la mémoire d'un labyrinthe +// met maze.data à NULL +void maze_free(maze_t maze); + +void maze_create(maze_t maze); + + + +int main(){ + + maze_print(maze_t maze) +} + +void maze_print(maze_t maze){ + + int size = maze.n; + + printf("size : %d", maze.data); + + + +} \ No newline at end of file