zltzlt 发表于 2020-1-29 12:21:18

Reversed Strings

Complete the solution so that it reverses the string value passed into it.

solution('world'); // returns 'dlrow'

#include <string>
using namespace std;

string reverseString (string str )
{
    string res = "";
    for (int i = (str.size() - 1); i >= 0; i--)
    {
      res += str;
    }
    return res;
}
页: [1]
查看完整版本: Reversed Strings