文章
11
粉丝
407
获赞
3
访问
123.7k
 
#include <bits/stdc++.h>
1:
char s[]="hello"; strrev(s); puts(s); return 0;
2:
string s= "hello"; everse(s.begin(),s.end()); cout<<s<<endl; return 0;
1.strrev函数只对字符数组有效,对string类型是无效的。
2.reverse函数是反转容器中的内容,对字符数组无效。
using namespace std;
int main()
{
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    cout<<s;
    return 0;
}
3:
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int f=0;
    int l=s.size()-1;
    char temp;
    while(f<l)
    {
        temp=s[f];
        s[f]=s[l];
        s[l]=temp;
        f++;
 &nbs...
登录后发布评论
暂无评论,来抢沙发