自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(29)
  • 资源 (1)
  • 收藏
  • 关注

翻译 找字符串的所有组合

#include #include #include #include using namespace std;void Combination(char* string, int number, vector& result){ if(number == 0) { vector::iterator iter = result.begin();

2013-05-07 11:00:35 603

翻译 去重的全排列

#include #include using namespace std;template void CalcAllPermutation_R(T perm[], int first, int num) { if (num <= 1) { cout<<perm<<endl; return; } for (in

2013-05-01 23:13:36 783

翻译 求链表倒数第K个节点

struct ListNode{ char data; ListNode * next;};ListNode *head,*p,*q;ListNode *pone, *ptwo;//让ONE 和 two的相隔为K,两个一致移动,后面的到末尾,前面的就指向倒数第K个了ListNode * fun(ListNode *head, int k){ assert(k>=0); pone

2013-04-30 13:43:28 1040

翻译 stcpbrk--在源字符串(s1)中找出最先含有搜索字符串(s2)中任一字符的位置并返回,若找不到则返回空指针。

//用途:在源字符串(s1)中找出最先含有搜索字符串(s2)中任一字符的位置并返回,若找不到则返回空指针。char *strpbrk1(const char *strSrc, const char *str){ assert(strSrc != NULL && str != NULL); const char *sc1,*sc2; for (sc1 = strSrc;*sc1 != '\

2013-04-30 01:04:04 738

翻译 比较前N个字符串大小 strncmp

//两个功能一样,注意count--的位置,放在WHILE中,等 *s == *t判断之后,我放在前面的话,临界就出了点问题。//比较字符串大小 s - tint strncmp1(const char *s, const char *t,unsigned int count){ assert(s != NULL && t != NULL); //断言保证传进来的参数不是空 whi

2013-04-30 00:31:31 1001

翻译 指定字符个数的strncat

//串连字符串,把strSrc前N个串到strDest后面去char *strncat1(char *strDest, const char *strSrc, unsigned int count){ assert(strDest != NULL && strSrc != NULL); //断言保证传进来的参数不是空 char *address = strDest; while (

2013-04-30 00:05:33 702

翻译 查找完全匹配的子字符串strstr

//包含文件:string.h//函数名: strstr//函数原型:extern char *strstr(char *str1, char *str2);//功能:查找完全匹配的子字符串。//返回值:返回该位置的指针,如找不到,返回空指针。char *strstr(char *strSrc, char *str){ assert(strSrc != NULL && st

2013-04-29 22:12:29 1510

翻译 将字符串拷贝到新位置

char *strdup1(const char *strSrc){ if (strSrc != NULL) { int len = 0; const char *start = strSrc; while (*strSrc++ != '\0') { ++len; } char *address = (char *)malloc(len +1); asser

2013-04-29 21:55:44 940

翻译 算字符串长度

//算字符串长度int strlen1(const char *str){ assert(str != NULL); int length = 0; while (*str++ != '\0') { ++length; } return length;}

2013-04-29 21:32:05 883

翻译 串连字符串strcat

#include #include using namespace std;//串连字符串char *strcat1(char *strDest, const char *strSrc){ assert(strDest != NULL && strSrc != NULL); //断言保证传进来的参数不是空 char *address = strDest; while (*s

2013-04-29 21:21:55 645

翻译 比较字符串大小strcmp

#include #include using namespace std;//比较字符串大小 s - tint strcmp(const char *s, const char *t){ assert(s != NULL && t != NULL); //断言保证传进来的参数不是空 while (*s && *t && *s == *t) //保证两者还有指向内容,

2013-04-29 21:05:06 1183

原创 /查找字符串str中首次出现c的位置

#include #include using namespace std;//查找字符串str中首次出现c的位置int strchr(char *str, char c){ assert(str != NULL); //断言保证传进来的参数不是空 int position = 1; while ( *str != '\0' ) { if (*str == c)

2013-04-29 20:58:30 842

翻译 实现strncpy函数

#include #include using namespace std;//实现strncpy函数,注意啊,中间带个N,就是从源字符串复制多少个过来,//返回值为目标字符串的地址是为了实现链式操作 char* strncpy(char *strDest, const char *strSrc, unsigned int count)//注意这里的CONST,指向的内容不能修改

2013-04-29 20:46:19 790

转载 最长重复子串

#include #include #include #define MAXN 5000000char c[MAXN], *a[MAXN];int comlen(char *p, char *q){ int i = 0; while(*p && (*p++ == *q++)) { i++; } return i;

2013-04-28 00:10:28 557

转载 全排列的递归实现

//全排列的递归实现#include #include void Swap(char *a, char *b){ char t = *a; *a = *b; *b = t;}//k表示当前选取到第几个数,m表示共有多少数.void AllRange(char *pszStr, int k, int m){ if (k == m) { static int s_i =

2013-04-27 22:56:26 468

原创 UC今天的题目,选择题,好像没答案,当场就郁闷了

#includeusing namespace std;#define ADD(x,y) x-yint main(){ int m =3; int n =4; m += m*ADD(n, m); cout<<m; system("pause"); }运行后答案是12的,因为宏的话,直接在那个地方替换,变成m+=m*n-m 应该=12,可是4个选项好像没有一个是。。。

2013-04-26 22:18:44 507

翻译 数组的循环移位

#include using namespace std;void Reverse(int *arr, int b, int e){ for (; b < e; b++,e--) { int temp = arr[b]; arr[b] = arr[e]; arr[e] = temp; }}void RightShift(int *arr,int N, int K)

2013-04-26 00:17:41 649

翻译 1的数目

补充一下,这不是最优的方法,只是最直观的方法!还有更优的方法,待续#include using namespace std;int Count1InAInteger(int n){ int iNum = 0; while (n != 0 ) { iNum += ( n % 10 == 1 )?1:0; n /=10; } return iNum;}int f(int

2013-04-25 22:55:57 447

翻译 最大公约数-减法和除法的合体,更快啊!

#include using namespace std;bool IsEven(int z){ if (z % 2 == 1) { return false; } else { return true; } }//来自编程之美int gcd(int x, int y){ if(x < y) { return gcd(y, x); } if(y =

2013-04-25 22:47:50 589

翻译 最大公约数-减法版

#include using namespace std;int gcd(int x, int y){ if(x < y){ return gcd(y,x); } if( y == 0){ return x; } else{ return gcd(x-y,y); }}int main(){ int x = 42; int y = 30; int x_y

2013-04-25 22:34:54 682

翻译 最大公约数问题

#include using namespace std;int gcd(int x, int y){ return (!y)?x:gcd(y, x%y);}int main(){ int x = 42; int y = 30; int x_y = gcd(x,y); cout<<x_y<<endl; system("pause");

2013-04-25 22:31:06 424

翻译 first single char

#include using namespace std;//first single char char firstSingle(char *str){ int a[255];//char 0-255 memset(a,0,sizeof(int)*255); char *p = str; while (*p != '\0') { a[*p]++; p++; } p

2013-04-23 21:27:40 504

转载 compare two string

#include using namespace std;//compare two stringint strcmp(char * p1, char* p2) { while (p1 != '\0' && p2 != '\0' && *p1 == *p2 ) { ++p1; ++p2; } if (*p1 == '\0' && *p2 == '\0') { retu

2013-04-23 21:03:09 628

转载 反转句子的词序,就是全部反一次,然后把每个词再返回来。

#include using namespace std;void reverseFixlen(char *str, int len){ char *p = str+len-1; while (str < p) { char c = *str; *str = *p; *p = c; ++str; --p; }}void reverse(char *str){

2013-04-23 00:03:49 771

原创 反转字符串,优化速度,优化空间。

#include using namespace std;void reverseFixlen(char *str, int len){ char *p = str+len-1; while (str < p) { char c = *str; *str = *p; *p = c; ++str; --p; }}void reverse(char *str){

2013-04-22 23:52:35 706

原创 看一个反向链表都没看懂,就写了下代码来测一下对不对

#include using namespace std;typedef struct Node{ int num; Node *next;}Node;Node * reverse(Node *head){ if(head == NULL){ return head; } if (head->next == NULL) { return head; } cou

2013-04-22 23:41:17 584

原创 htmlunit应用到爬虫上来解析JS的问题(javascirpt 解析)

我目前致力于解决怎么在搜索引擎的爬虫中的解析问题,具体是怎么解析动态网页中的URL出来,这些URL需要JAVASCRIPT的解析才能获得完整的链接信息,不是简单地找href,window.open,location然后用正则表达式就能解决。尝试用htmlunit这个JAVA的模拟浏览器来解决这个问题,里面使用了rhino犀牛这个javascript解析引擎.(目前我用最新版2.12了)目前

2013-04-10 10:12:38 4160 17

转载 二叉树转双向链接表_LEARN FORM CSDN JULY

发现写个代码不容易,虽然很明白怎么回事,但是道和术是不同的,术需要懂得代码实现的细节,下面的代码,好几个地方一开始写错,死活运行不了,现在行了。。有问题请不吝赐教!/* * BSTree2BILinkList.cpp * * Created on: 2013-4-2 * Author: CJ */#includeusing namespace std;

2013-04-02 22:14:27 576

原创 演示顺序线性表的例子

看了数据结构的书,为了动动手,仿着程杰老师的代码,写了下面一个演示顺序线性表的例子,优点是去元素的时候O(1)就能解决,不好的地方是浪费空间啊。/* * list.cpp * * Created on: 2013-4-1 * Author: CJ */#include using namespace std;#define MAXSIZE 20

2013-04-01 22:17:12 742 2

DES加密算法在银行外联业务中的应用

DES加密算法在银行外联业务中的应用,可以参考一下

2011-04-29

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除