Week 1: Suggestion 1
Write a program to ask a user for their name and output their name in reverse order.
Such as:
INPUT: James
OUTPUT: semaJ.
Scrivi un programma che chiede il nome all’utente e poi lo visualizza in ordine inverso.
Soluzione 1
TextWindow.Write("Inserisci il tuo nome: ")
nomeInput=TextWindow.Read()
nomeOutput=""
For i=Text.GetLength(nomeInput) To 1 Step -1
nomeOutput=Text.Append(nomeOutput, Text.GetSubText(nomeInput, i, 1))
EndFor
TextWindow.WriteLine(nomeInput + " rovesciato diventa " + nomeOutput)
Soluzione 2
Utilizzo lo Stack
TextWindow.Write("Inserisci il tuo nome: ")
nomeInput=TextWindow.Read()
num=Text.GetLength(nomeInput)
For i=1 to num
car=Text.GetSubText(nomeInput, i, 1)
Stack.PushValue("capovolgi", car)
EndFor
For i=1 to num
car=Stack.PopValue("capovolgi")
TextWindow.Write(car)
EndFor
TextWindow.WriteLine("")