coder_new

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2014年3月13日

摘要: //假设这有两个分别由字母组成的字符串A另外字符串B,字符串B的字母数较字符串A少一些。//什么方法能最快地查出字符串B所有字母是不是都在字符串A里?//也就是说判断字符串B是不是字符串A的真子集(为了简化,姑且认为两个集合都不是空集,即字符串都不为空。)。为了简单起见,我们规定输入的字符串只包含大写英文字母。//实现函数bool compare(string &A,string &B)//int 32位,使用一个整数来hash#include using namespace std;bool compare(string &a,string &b){ int 阅读全文
posted @ 2014-03-13 16:46 coder_new 阅读(178) 评论(0) 推荐(0) 编辑

摘要: //左旋转字符串#include using namespace std;//一位位移动void shiftLeftOne(char *str){ int len=strlen(str); char temp=str[0]; for(int i=1;i<len;i++) { str[i-1]=str[i]; } str[len-1]=temp;}char *shiftLeft(char *str,int n){ int len=strlen(str); n=n%len; while(n--) { shiftLeftOn... 阅读全文
posted @ 2014-03-13 15:48 coder_new 阅读(186) 评论(0) 推荐(0) 编辑