1
input example:
rmtpuzcafhnyxdesivlkbwgjqo
2
roahp
uhchch
exit :
veras
batata
Code:
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main()
{
char palavra[ 1000 ];
char alfabeto[ 26 ];
char codificacao[ 1000 ];
int N, i, tam, j, indice;
scanf( "%s", alfabeto );
scanf( "%d", &N );
for( i = 0; i < N; i++ )
{
scanf( "%s", palavra );
}
tam = strlen( palavra );
for( j = 0; j < tam; j++ )
{
palavra[ j ] = toupper( palavra[ j ] );
indice = palavra[ j ] - 65;
codificacao[ j ] = alfabeto[ indice ];
}
printf( "%s\n", codificacao );
return 0;
}
your print must be inside the for
– Murilo Melo
When I put it inside the is, it prints character by character of the last output, in case, b,ba,bat,bata,batat,potato,...
– Bruno Santos
do not know how it is done in C, however, you can inside your for, concatenate the strings and insert in a variable, so at the end, outside of the for, printe the result
– Murilo Melo