下面介绍了两种字符串逆转的方法
#include < iostream >
#include<bits/stdc++.h>
#include< algorithm>
#include< string>
using namespace std;
#define N 20
#define M 30
int main ()
{
int len;
char ch[N]={“hello world!”};
len=strlen(ch);
reverse(ch,ch+len);
cout<<ch<<endl;
string str=“I love world,but world do not love me!!!”;
reverse(str.begin(),str.end());
cout<<str<<endl;
return 0;
}
字符串逆转
最新推荐文章于 2023-06-18 10:00:30 发布