码迷,mamicode.com
首页 > 其他好文 > 详细

字符串翻转

时间:2015-06-26 16:17:33      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:字符串翻转

比如将"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;
}

技术分享

字符串翻转

标签:字符串翻转

原文地址:http://blog.csdn.net/u013018721/article/details/46650823

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!