From c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:08:27 +0200 Subject: add: graphs et rushs --- graphs/piscine/str_revert/str_revert.c | 25 +++++++++++++++++++++++++ graphs/piscine/str_revert/str_revert.h | 6 ++++++ 2 files changed, 31 insertions(+) create mode 100644 graphs/piscine/str_revert/str_revert.c create mode 100644 graphs/piscine/str_revert/str_revert.h (limited to 'graphs/piscine/str_revert') diff --git a/graphs/piscine/str_revert/str_revert.c b/graphs/piscine/str_revert/str_revert.c new file mode 100644 index 0000000..31f7f3d --- /dev/null +++ b/graphs/piscine/str_revert/str_revert.c @@ -0,0 +1,25 @@ +#include "str_revert.h" + +#include + +void str_revert(char str[]) +{ + if (*str == '\0') + { + return; + } + + size_t len = 0; + for (; str[len]; len++) + { + continue; + } + len--; + + for (size_t i = 0; i <= len / 2; i++) + { + char tmp = str[i]; + str[i] = str[len - i]; + str[len - i] = tmp; + } +} diff --git a/graphs/piscine/str_revert/str_revert.h b/graphs/piscine/str_revert/str_revert.h new file mode 100644 index 0000000..daa23d4 --- /dev/null +++ b/graphs/piscine/str_revert/str_revert.h @@ -0,0 +1,6 @@ +#ifndef STR_REVERT_H +#define STR_REVERT_H + +void str_revert(char str[]); + +#endif /* ! STR_REVERT_H */ -- cgit v1.2.3