Last active
October 13, 2021 15:14
-
-
Save fabiommendes/92898922f022acd1da2bc85f3e1f84e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <math.h> | |
#include <string.h> | |
/** | |
* Aplica a cifra de César na string de entrada. | |
* | |
* Modifica o argumento durante a aplicação. | |
*/ | |
void cesar(char *msg) | |
{ | |
int n = strlen(msg); | |
for (int i = 0; i < n; i++) | |
{ | |
char c = msg[i]; | |
if (c >= 'a' && c <= 'z') | |
{ | |
msg[i] = (c + 3 - 'a') % 26 + 'a'; | |
} | |
if (c >= 'A' && c <= 'Z') | |
{ | |
msg[i] = (c + 3 - 'A') % 26 + 'A'; | |
} | |
} | |
} | |
int main() | |
{ | |
char msg[101]; | |
int n = 42; | |
fgets(msg, 100, stdin); | |
cesar(msg); | |
printf("%s\n", msg); | |
printf("%d\n", n); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment