Convert letter by number to visualG

Asked

Viewed 1,592 times

1

Is it possible to create an algorithm in visualg that reads a letter and transforms it by another letter or by a number that was already stored in the algorithm? As a simple encryption?

The logic would be :

A = B
B = C
C = D

If typed A, it would appear at the end B, and successively.

The ultimate goal would be to read whole sentences with spaces and exchange them for numbers or letters.. But for now, I want to know if it can be done in viualG.

I started doing it, but the feeling is wrong. Ex.:

   Escreval("Escreva uma letra de A a D para conversão: ")
     leia(textoc)
     textoc <- textocc
    se textoc = a entao
   escreval("Texto codificado: ")
 escreval("b")
fimse

1 answer

0

Try to use asc to convert the letter to a number according to the ascii table, manipulate the number and then use carac to convert back to text.

Escreval("Escreva uma letra de A a D para conversão: ")
leia(textoc)
z <- asc(textoc)
z <- z + 1
textocc = carac(z)
escreval("Texto codificado: ")
escreval(textocc)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.