diff --git a/level00/ressources/rotX.c b/level00/ressources/rotX.c new file mode 100644 index 0000000..c27b521 --- /dev/null +++ b/level00/ressources/rotX.c @@ -0,0 +1,20 @@ +#include + +char rotate_char(char c, int rot) { + return (c - 'a' + rot) % 26 + 'a'; +} + +void rotate_string(const char *input, int rot) { + printf("rot%d:\t", rot); + for (int i = 0; input[i] != '\0'; i++) { + printf("%c", rotate_char(input[i], rot)); + } + printf("\n"); +} + +int main() { + char input[] = "cdiiddwpgswtgt"; + for (int rot = 1; rot <= 25; rot++) { + rotate_string(input, rot); + } +}