标签:函数 class eve ring ever include code stream tps
https://leetcode.com/problems/reverse-string/
编写一个以字符串作为输入并逆转字符串的函数。
字符串大于0,就从最末尾开始取值。
#include "pch.h"
#include <stdio.h>
#include <string>
#include <iostream>
#include <algorithm>
using std::string;
class Solution {
public:
string reverseString(string s) {
string result = "";
for (int i =s.length()-1;i>=0 ; i--)
{
result += s.at(i);
}
return result;
}
};
int main()
{
// 使用内容
Solution nSolution;
nSolution.reverseString("abcdef");
}
标签:函数 class eve ring ever include code stream tps
原文地址:https://www.cnblogs.com/17bdw/p/10358173.html