比如将"vpoet" 变为“teopv”
#include <iostream>
using namespace std;
int main()
{
char Before_Str[100]={0};
cout<<"******************************vpoet*********************************\n";
cout<<"Please input the String you want to reverse:";
cin>>Before_Str;
char Ch_Temp;
int Len=strlen(Before_Str);
for(int i=0;i<Len/2;i++)
{
Ch_Temp=Before_Str[i];
Before_Str[i]=Before_Str[Len-i-1];
Before_Str[Len-i-1]=Ch_Temp;
}
cout<<"After reverse:"<<Before_Str<<endl;
return 0;
}
本文介绍了一个简单的C++程序,用于实现字符串的反转操作。通过用户输入的字符串,程序使用字符数组和循环来交换前后字符的位置,最终输出反转后的字符串。
1113

被折叠的 条评论
为什么被折叠?



