keep it simple, stupid

导航

2011年9月8日 #

将一个长度为n的字符串向左循环移动m位

摘要: // 将一个长度为n的字符串向左循环移动m位,如:hello,world向左移动3位就变成了lo,worldhel// 思路:把字符串切成长为m和n-m的两半,先分别对两部分进行逆序,最后对整个字符串逆序。#include <iostream>using namespace std;void ReverseString(char * const str, const int count);void RotateLeft(char *str, int num);int _tmain(int argc, char *argv[]){ char str[] = "hello,w 阅读全文

posted @ 2011-09-08 11:52 tujiaw 阅读(528) 评论(0) 推荐(0)

将字符串中的单词进行倒序

摘要: // 将字符串中的单词进行倒序,如:hello,world 倒序后:world,hello// 思路:先将整篇文章进行倒序,然后将所有单词进行倒序// 整篇文章倒序:dlrow,olleh// 所有单词倒序:world,hello#include <iostream>using namespace std;void ReverseString(char * const str, const int count);void ReverseAllWord(char *str);int _tmain(int argc, char *argv[]){ char str[] = " 阅读全文

posted @ 2011-09-08 11:25 tujiaw 阅读(354) 评论(0) 推荐(0)