异或翻转字符串:String:Improve my method of reverse a string
来源:互联网 发布:温州动车事故真相 知乎 编辑:程序博客网 时间:2024/06/06 00:14
// TestString.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream"
#include "string"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
char s[]="How are you!!";
int len=strlen(s);
int high=len-1;
for(int m=0;m<high;m++,high--)
{
s[m]^=s[high];
s[high]^=s[m];
s[m]^=s[high];
}
for(int p=0;p<len;p++)
cout<<s[p]<<" ";
cout<<endl;
int start=0,end=0;
for(int i=0;i<len;i++)
{
if(s[i]=='.'||s[i]=='!'||s[i]==':'||s[i]==',')
start+=1;
if(s[i]==' ')
end=i-1;
if(i==len-1)
end=i;
for(int j=start,k=end;j<k;j++,k--)
{
s[j]^=s[k];
s[k]^=s[j];
s[j]^=s[k];
}
start=end+1;
}
for(int p=0;p<len;p++)
cout<<s[p]<<" ";
cin.get();
return 0;
}
- 异或翻转字符串:String:Improve my method of reverse a string
- Reverse Words in a String 翻转字符串
- JavaScript实现-字符串翻转-Reverse a String
- JavaScript实现-字符串翻转-Reverse a String
- Reverse String 翻转字符串
- Reverse Word in a String(improve)
- 【leetcode】 Reverse Vowels of a String(翻转字符串中出现的元音字母)
- 字符串-Reverse Words in a String(翻转字符串)
- Reverse Vowels of a String 仅翻转元音字符
- 递归翻转string Reverse a String recursively
- 【LintCode】Reverse Words in a String 翻转字符串
- 151. Reverse Words in a String 翻转字符串中的单词
- leetcode 151. Reverse Words in a String 字符串 翻转
- 【LintCode】Reverse Words in a String 翻转字符串
- FCC算法:一、Reverse a String--翻转字符串
- LeetCode 344. Reverse String(字符串翻转)
- LeetCode 344: Reverse String (字符串翻转)
- Python翻转字符串(reverse string)详解
- 动态分配资源的自动释放 - auto_ptr的实现原理
- 迅雷默认火狐下载工具
- 小问题有多学问
- 围脖---微博
- MySQL 数据库 InnoDB引擎的插值问题
- 异或翻转字符串:String:Improve my method of reverse a string
- 怎样做好程序员
- MATLAB命令大全
- Subclipse中submit的时候填写的comment中不允许有回车?
- 图论基础
- 一个烟蒂
- 堆栈选择性翻转字符串:String:Reverse a string using Stack:the pointer is a very good tool actually
- begin?
- 出轨的女人,十头牛