-1
Hello, could you help me solve this problem in my code ? In the case it was asked to develop an algorithm that performs an encryption on a text. The algorithm must invert the characters of each line of the text. That is, in a given line the character at position 0 will take position n - 1, character 1 will be n - 2 and so on, where n is the line size. Additionally the algorithm when identifying a vowel will replace following the table below:
Vowel Character that replaces to or A @ and or AND # i or I ! o or O * u or U $
Restrictions and rules of your program: • Assume that the input text will not exceed 32 lines, and that the size of each line will not have more than 128 characters counting with the ? 0' • To finish reading the input text the user will enter "FIM_TEXTO", that should not enter the final matrix • No need to treat any accentuation
My code is this, but I don’t know where I’m going wrong.
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
#define MAX_LINHAS 32
#define MAX_CARACTERES 128
typedef struct
{
char frase[MAX_LINHAS];
} dados;
int main ()
{
char texto[MAX_LINHAS][MAX_CARACTERES];
int i, j =0;
printf ("Digite uma linha em branco para sair do programa.\n");
for (int i =0; i< MAX_LINHAS ; i++) // Gera a matriz
{
printf ("%d",i+1);
fgets(texto[i],MAX_CARACTERES, stdin);
if (texto[i][0] == '\n')
{
break;
}
}
for (j=0; j<i; j++)
{
printf ("%03d",j+1,texto [j]);
}
system("pause");
return 0;
}
void criptografa(dados *cripto)
{
printf("DIGITE UMA FRASE: \n");
gets(cripto->frase);
for(int i = 0 ; i < strlen(cripto->frase) ; i++)
{
if(cripto->frase[i] == 'a')
{
cripto->frase[i] = '@';
}
else if(cripto->frase[i] == 'e')
{
cripto->frase[i] = '#';
}
else if (cripto->frase[i] == 'i')
{
cripto->frase[i] = '!';
}
else if (cripto->frase[i] == 'o')
{
cripto->frase[i] = '*';
}
else if (cripto->frase[i] == 'u')
{
cripto->frase[i] = '$';
}
else if(cripto->frase[i] == 'A')
{
cripto->frase[i] = '@';
}
else if(cripto->frase[i] == 'E')
{
cripto->frase[i] = '#';
}
else if (cripto->frase[i] == 'I')
{
cripto->frase[i] = '!';
}
else if (cripto->frase[i] == 'O')
{
cripto->frase[i] = '*';
}
else if (cripto->frase[i] == 'U')
{
cripto->frase[i] = '$';
}
else
{
cripto->frase[i] = cripto->frase[i] ;
}
}
for(int i = 0 ; i< strlen(cripto->frase); i++)
{
putchar(cripto->frase[i]);
}
printf("\n\n");
for(int i = strlen(cripto->frase) ; i>=0 ; i--)
{
putchar(cripto->frase[i]);
}
printf("\n\n");
//IMPRIME TEXTO:
printf("TEXTO DEPOIS DE PROCESSADO: \n");
for(int i = 0; i< tamanho; i++)
{
printf("LINHA %d: %s\n", i, texto[i]);
}
}