
Algorithm
文章平均质量分 61
modosxiaoyao
这个作者很懒,什么都没留下…
展开
-
判断两个字符串是否有相同的字符
bool Anagram(char* src, char* dest){ int letters [256] = {0}; if(sizeof(src)!=sizeof(dest)) return false; // Get the size of all string int size = sizeof(src); // Hit is used for counting all di原创 2012-09-06 08:52:48 · 1190 阅读 · 0 评论 -
将空格替换为百分号,效率为O(size)
void replace(char* str, int len){ int space = 0, counter = 0; for(int i = 0; i { if(str[i] == ' ') space ++; } int newLength = space+len*2+1; char *newStr = new char[newLength]; for(int i =原创 2012-09-06 09:09:56 · 1349 阅读 · 0 评论