0
I want to print the output exactly as below, but the code is giving the output in each entry.
Entrances
- rmtpuzcafhnyxdesivlkbwgjqo
- 3
- roahp
- uhchch
- veras
Exits
- veras
- potato
- wuvrl
#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main() {
char string[1000];
char alfabeto[26];
char misterio[1000];
int N, i, tam, j, indice,z;
scanf("%s", alfabeto);
scanf("%d", &N);
for(i = 0; i < N; i++) {
scanf("%s", string);
tam = strlen(string);
for(j = 0; j < tam; j++){
string[j] = toupper(string[j]);
indice = string[j] - 65;
misterio[j] = alfabeto[indice];
}
printf("%s", misterio);
}
return 0;
}
Start by separating in the question what is code and what is explanation of the problem itself. Take advantage of detail about what your program is supposed to do and where it’s not doing what it’s supposed to do.
– Isac