0
Example: in the sentence naruto
, the letter n
vector frase
is in position frase[0]
.
I want to put it on mat_cript
position [0][0]
.
Not only her, the rest of the sentence too.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <conio.h>
#include <time.h>
int main()
{
char frase[25];
char mat_cript[i][j];
int chave, tamanho_frase, cont,i,j;
system("cls");
printf("Digite a frase a ser criptografada : ");
gets(frase);
while(chave<1 || chave>25)
{
printf("Digite a chave a ser utilizada (<= 25) : ");
scanf("%d",&chave);
fflush(stdin);
}
tamanho_frase = strlen(frase);
for(cont=0;cont<tamanho_frase;cont++)
frase[cont] = frase[cont]+chave;
printf("\n\nFRASE CRIPTOGRAFADA : %s",frase);
getchar();
for(i=0;i < tamanho_frase;i++){
for(j=0;j< tamanho_frase;j++){
mat_cript[i][j]=frase[i];
}
}
for(i=0;i < tamanho_frase;i++){
for(j=0;j< tamanho_frase;j++){
printf(" %d°elemento da linha %d, coluna %d: %s",j+1;i+1;j+1;mat_cript[i][j]);
}
}
}
Hi Gabriel , as it would look for a sentence of n characters and filling the rest of the indexes with random characters
– Roni
@Roni edited the answer. First it already picks from
n
characters, which is what it does instrlen(frase);
. In the code it arrow random values and then, fill with the phrase you want, according to the position you want, there is your control where it will be inserted.– Gabriel Gonçalves
thanks, I’m doing a transposition encryption and honestly ...I don’t know if I’ll be able to.
– Roni
@Roni if the answer helped you, mark it as accepted and try to do yes, any questions, just call
– Gabriel Gonçalves