Can anyone please give me code of this question in c++ with the basic algorithm, I m a beginner. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Can anyone please give me code of this question in c++ with the basic algorithm, I m a beginner.

You meet a group of aliens, and their language is just like English except that they say every word backwards. How will you learn to communicate with them? Task: Take a word in English that you would like to say, and turn it into language that these aliens will understand. Input Format: A string of a word in English. Output Format: A string of the reversed word that represents the original word translated into alien language. Sample Input: howdy Sample Output: ydwoh

4th Mar 2021, 5:02 PM
Prachi Agrawal
1 Answer
+ 3
What do you gain by having others solve this simple code coach for you? Here are threads showing how to reverse strings in C++, which is essentially the task: https://stackoverflow.com/questions/4951796/how-to-reverse-an-stdstring https://www.geeksforgeeks.org/reverse-a-string-in-c-cpp-different-methods/amp/ Basically, you just have to declare a string: std::string _s; Get the input, where std::cin is sufficient since no spaces appear: std::cin >> _s; And then reverse and print the string using a method of your choice, e.g. via std::reverse() or std::reverse_copy(): https://en.cppreference.com/w/cpp/algorithm/reverse https://en.cppreference.com/w/cpp/algorithm/reverse_copy
4th Mar 2021, 5:19 PM
Shadow
Shadow - avatar