Last active
August 29, 2015 14:13
-
-
Save arielmoraes/7cc61811510ab368d9b2 to your computer and use it in GitHub Desktop.
Desafio001 do Ciência da Computação depressão - Cifra de César
This file contains 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
// Ariel Moraes | |
// https://www.linkedin.com/in/arielmoraes | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <math.h> | |
int mathmod(int a, int b) { | |
return (abs(a * b) + a) % b; | |
} | |
int main(int count, char* args[]) | |
{ | |
char texto[] = "Me encontre na Av. Olimpos em frente ao teatro as 19:00!"; | |
const int shiftsize = 3; | |
for (int i = 0; i < strlen(texto); i++) { | |
texto[i] = mathmod(texto[i] + shiftsize - 32, 94) + 32; | |
} | |
FILE *f = fopen("resultado.txt", "w"); | |
if (f == NULL) | |
{ | |
printf("Erro ao criar arquivo\n"); | |
return 1; | |
} | |
fprintf(f, "%s\n", texto); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment