+ 1
I dont understand how is sample output : vool dliow
Cod cach : "secrate message: Task: Create a program that replaces each letter in a message with its corresponding letter in a backwards version of the English alphabet. Input Format: A string of your message in its normal form. Output Format: A string of your message once you have encoded it (all lower case). Sample Input: Hello World Sample Output: svool dliow
5 ответов
+ 4
Edit Sajid Ali I just posted the answer based on your code. Sorry for misunderstanding 🙏
You should mention that it's the code coach problem "Secret message" and post the appropriate code.
The task said:
"Create a program that replaces each letter in a message with its corresponding letter in a backwards version of the English alphabet.
"
So according to task,
a = z
h = s
e = v
.
.
and so on..
+ 1
I just try to make reverse string but..
Look..
..https://code.sololearn.com/ci9cL7aX18s2/?ref=app
+ 1
Minho 🇰🇷 i knew that,,,
See my question abobe said!..
If i am input :
"hello world"
Output : dlrow olleh
But above said sample output : svool dliow
0
Sajid Ali, show your attempt...
0
Um, I think this thing, needs to be added to reverse text:
byte[] strAsByteArray = text.getBytes();
byte[] result = new byte[strAsByteArray.length];
And you are printing text over an array:
The solution:
for (int i = 0; i < strAsByteArray.length; i++) {
result[i] = strAsByteArray[strAsByteArray.length - i - 1];
System.out.println(new String(result));
}
I hope this works....