字符串翻转

比如将"vpoet" 变为“teopv”

 1 #include <iostream>
 2 using namespace std;
 3 
 4 int main()
 5 {
 6     char Before_Str[100]={0};
 7     
 8     cout<<"******************************vpoet*********************************\n";
 9     cout<<"Please input the String you want to reverse:";
10     cin>>Before_Str;
11 
12     char Ch_Temp;
13 
14     int Len=strlen(Before_Str);
15 
16     for(int i=0;i<Len/2;i++)
17     {
18         Ch_Temp=Before_Str[i];
19         Before_Str[i]=Before_Str[Len-i-1];
20         Before_Str[Len-i-1]=Ch_Temp;
21     }
22 
23     cout<<"After reverse:"<<Before_Str<<endl;
24     return 0;
25 }

posted @ 2015-06-26 15:44  vpoet  阅读(227)  评论(0编辑  收藏  举报