每日一”鞭“
文章平均质量分 57
wobuaishangdiao
我是一个快乐的小傻子,每天不打烊,每天坚持学习自己喜欢的。
展开
-
每日一鞭_字符串左移(一)反转
实现一个字符串的左移,利用的是反转原理即// 反转的原理:(X^TY^T)=YX#include "iostream"using namespace std;//反转的原理:(X^TY^T)=YXchar* invert(char* start, char *end){ char tmp, *ptmp = start; while(start != NULL && end !原创 2012-11-23 00:16:15 · 403 阅读 · 0 评论 -
每日一鞭_字符串左移(三)递归实现
#include "iostream"using namespace std;void rotate(string &str, int n, int m, int head, int tail, bool flag){ //n 待处理部分的字符串长度,m:待处理部分的旋转长度 //head:待处理部分的头指针,tail:待处理部分的尾指针 //fl原创 2012-11-29 00:27:04 · 429 阅读 · 0 评论 -
每日一鞭_字符串左移(二)指针实现
字符串的左移:#include "iostream"using namespace std;void invert(char *arr, int m){ //指针偏移类型,首先整数的偏移 int len = strlen(arr); int num = len/m; //偏移的整倍 char *p1, *p2; p1 = arr; p2 = arr +原创 2012-11-25 13:23:50 · 889 阅读 · 0 评论 -
每日一鞭之字符串左移_STL(rotate)
1. gcd()最大公约数球法:2. 左移方案:#include "iostream"using namespace std;//STL rotate//gcd 辗转相除法(欧几里德算法,求最大公约数算法)int gcd(int m, int n);void rotate(string &str, int m){ int lenOfStr = str.len原创 2012-12-09 08:09:21 · 687 阅读 · 0 评论 -
每日一鞭(二)字符串的查找(轮询方法)
就是一个一个的对应,最后的计算的时间是O(n*m)//轮询方法O(n*m)#include "iostream"using namespace std;int compareString(string longString, string shortString){ int longLength = longString.size(); int shortLength = sho原创 2012-12-13 23:33:12 · 535 阅读 · 0 评论