摘要:
题目:将字符串原地压缩,比如"eeeeeaaaff"压缩为 "e5a3f2"。答:#include "stdafx.h"#include <iostream>using namespace std;//字符串原地压缩void CompressString(char *str){ if (NULL == str) { return; } int count = 0; char *newStr = str; char ch = *str; while (*str != '\0') { if (*str != c 阅读全文
posted @ 2012-09-03 22:27
venow
阅读(2474)
评论(1)
推荐(1)
摘要:
题目:给定两个字符串s1和s2,要求判定s2是否能够被s1做循环移位得到的字符串包含。例如,给定s1=AABCD和s2=CDAA,返回true;给定s1=ABCD和s2=ACBD,返回false。答:#include "stdafx.h"#include <iostream>using namespace std;//获取next数组的值void GetNext(const char* pattern, int length, int *next){ int i = 0; next[i] = -1; int j = -1; while (i < lengt 阅读全文
posted @ 2012-09-03 20:30
venow
阅读(330)
评论(0)
推荐(0)
摘要:
题目:已知一个字符串,比如asderwsde,寻找其中的一个子字符串比如sde的个数,如果没有返回0,有的话返回子字符串的个数。答:#include "stdafx.h"#include <iostream>using namespace std;//获取next数组的值void GetNext(const char* pattern, int length, int *next){ int i = 0; next[i] = -1; int j = -1; while (i < length - 1) { if (-1 == j || pattern... 阅读全文
posted @ 2012-09-03 20:17
venow
阅读(1792)
评论(0)
推荐(0)
摘要:
#include "stdafx.h"#include <iostream>using namespace std;//获取next数组的值void GetNext(const char* pattern, int length, int *next){ int i = 0; next[i] = -1; int j = -1; while (i < length - 1) { if (-1 == j || pattern[i] == pattern[j]) { i++; j++; ... 阅读全文
posted @ 2012-09-03 19:29
venow
阅读(531)
评论(0)
推荐(0)
浙公网安备 33010602011771号