【发布时间】:2022-01-22 14:26:04
【问题描述】:
这段代码有什么问题?即使我写了 s.reverse(),字符串也没有反转。它显示相同的字符串而不反转?有人可以帮我解决这个问题吗?
#include<iostream>
using namespace std;
int main(){
cout << "Hello world" << endl;;
string s;
cin >> s;
s.reverse();
cout << s;
}
【问题讨论】:
-
reverse方法需要 2 个参数 - 开始和结束迭代器 -
是的,谢谢@CS,知道了。