feat(lvl00/ressources): adding the program to test all rot
This commit is contained in:
parent
96360c3373
commit
6d4c37d7aa
1 changed files with 20 additions and 0 deletions
20
level00/ressources/rotX.c
Normal file
20
level00/ressources/rotX.c
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue