Convert letter by number in visualG

0

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 simple encryption?

The logic would be:

A = B
B = C
C = D

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

The final goal would be to read whole phrases with spaces and change by numbers or letters .. But for now, I want to know if you can do it in viualG.

I started doing, but the syntax 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
    
asked by anonymous 29.03.2018 / 22:39

1 answer

0

Try using 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)
    
29.03.2018 / 23:58