随笔分类 -  技术-编程-C/C++

摘要:#include #include using namespace std; void printBit (unsigned int value) { unsigned int bits = sizeof(unsigned int) * 8; stringstream s; for (int i=0; i> bits-1-i; s > (bits-1-... 阅读全文
posted @ 2018-12-23 19:15 super行者
摘要:例如字符串aabbbc,插入字符个数后变成aa2bbb3c1 阅读全文
posted @ 2018-12-23 19:15 super行者
摘要:1. 把字母替换成它后面的第4个字母。如:a->e, A->E, X->b, y->c 2. 翻转整个字符串 阅读全文
posted @ 2018-12-23 19:14 super行者
摘要:empty() 堆栈为空则返回真 pop() 移除栈顶元素 push() 在栈顶增加元素 size() 返回栈中元素数目 top() 返回栈顶元素 阅读全文
posted @ 2018-12-23 19:13 super行者
摘要:include #include using namespace std; bool strToInt (char * strIn, int * valueOut) { if ((strIn==NULL) || (valueOut==NULL)) { return false; } bool status = false; int v... 阅读全文
posted @ 2018-12-23 19:12 super行者
摘要:#include using namespace std; char * strcpy1 (char * strDest, char * strSrc) { if ((strDest==NULL) || (strSrc==NULL)) { return NULL; } char * strDeskCpy = strDest; while ... 阅读全文
posted @ 2018-12-23 19:11 super行者
摘要:#include #include using namespace std; void * memcpy1 (void * desAddr, const void * srcAddr, unsigned int count) { assert ((desAddr!=NULL) && (srcAddr!=NULL)); char * from = NULL; char ... 阅读全文
posted @ 2018-12-23 19:10 super行者
摘要:#include #include #include using namespace std; const char * strstr1 (const char * src, const char * des) { assert ((src!=NULL)&&(des!=NULL)); int srcLen = strlen(src); int desLen = st... 阅读全文
posted @ 2018-12-23 19:09 super行者 阅读(217) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std; char * revStrExcludeSub (char * src, char * sub) { if ((src==NULL) || (sub==NULL)) return NULL; char * head=src, * tail=src, * pSub=sub; ... 阅读全文
posted @ 2018-12-23 19:08 super行者
摘要:#include #include using namespace std; char * revStr (char * src, int len) { if (len <= 1) return src; *src ^= *(src+len-1); *(src+len-1) ^= *src; *src ^= *(src+len-1); return (... 阅读全文
posted @ 2018-12-23 19:07 super行者
摘要:#include #include #include using namespace std; int validateInt (const char * src) { if (src == NULL) return 0; const char * p = src; while (*p>='0' && *p st; while (pA >= a) {... 阅读全文
posted @ 2018-12-23 19:06 super行者
摘要:#include #include using namespace std; // not using string library char * rightLoop1 (char * src, int n) { if (src==NULL) return NULL; char * p = src; while (*p++); int len = p-1-sr... 阅读全文
posted @ 2018-12-23 19:05 super行者
摘要:#include #include using namespace std; // pos starting from 0 char * deleteChars1 (char * src, int pos, int len) { if ((src==NULL) || (posp) || (src+pos+len-1>p)) return NULL; memcpy (src+p... 阅读全文
posted @ 2018-12-23 19:04 super行者
摘要:将字符串分成两部分,前半部分按ASCII码升序排序,后半部分不变(如果字符串是奇数个,则中间的字符不变)再将前后两部分交换,最后将该字符串输出。 阅读全文
posted @ 2018-12-23 19:02 super行者
摘要:#include #include using namespace std; char * deleteChar (char * src, char c) { if (src == NULL) return NULL; char * p = src; char * head = src; while (*p != '\0') { if ... 阅读全文
posted @ 2018-12-23 19:01 super行者
摘要:#include <iostream>#include <string.h>using namespace std;char * strcat1 (char * dest, char * src){ if ((dest==NULL) || (src==NULL)) return NULL; char 阅读全文
posted @ 2018-12-23 19:00 super行者
摘要:汉字作为一个字符处理,已知:汉字编码为双字节,其中首字节<0,尾字节在0~63以外(如果一个字节是 -128 ~ 127) 阅读全文
posted @ 2018-12-23 18:59 super行者
摘要:#include #include using namespace std; void calculate (const char * src, int * max0, int * max1) { if (src == NULL) return; int tmpCnt=1; *max0 = 1; *max1 = 1; while (*src++) ... 阅读全文
posted @ 2018-12-23 18:58 super行者
摘要:#include #include using namespace std; char * replace (char * in, char * s1, char * s2, char *out) { if ((in==NULL)||(s1==NULL)||(s2==NULL)||(out==NULL)) return NULL; char *pOut = out; ... 阅读全文
posted @ 2018-12-23 18:57 super行者
摘要:#include #include using namespace std; #define BIT(n) (0x1 T set_bit (T value, T bit_n) { value |= BIT(bit_n); return value; } template T clear_bit (T value, T bit_n) { value &= ~BIT(b... 阅读全文
posted @ 2018-12-23 18:56 super行者