首页 > 其他 > 详细

字符串翻转

时间:2017-08-10 20:22:01      阅读:215      评论: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://www.cnblogs.com/slgkaifa/p/7341057.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!