摘要:
#!/usr/bin/python import xml.etree.ElementTree as etree tree = etree.parse(wordbook.xml')root = tree.getroot()print len(root) entries = tree.findall(' 阅读全文
posted @ 2018-12-23 19:36
super行者
阅读(141)
评论(0)
推荐(0)
摘要:
看这篇帖子的,我想都是电子爱好者或电类专业学生。不知道大家都处于什么一个阶段,这篇帖子是写给入门者的,要解决一个问题:初学者应重点掌握什么电子知识,大学阶段如何学习? 先说点貌似题外的东西——3个谬论。 谬论一:高中老师常对我们说,大家现在好好学,考上了大学就轻松了,爱怎么玩怎么玩。这真是狗屁。别的 阅读全文
posted @ 2018-12-23 19:27
super行者
阅读(162)
评论(0)
推荐(0)
摘要:
#include using namespace std; unsigned int strlen1(const char * str) { const char * p = str; while (*p++ != '\0'); return (p-1-str); } int main() { char a[] = "12345"; cout << st... 阅读全文
posted @ 2018-12-23 19:19
super行者
阅读(142)
评论(0)
推荐(0)
摘要:
#include #include using namespace std; // rever letters of a string char * strRevert1 (char * src) { if (src == NULL) return NULL; int len = strlen(src); for (int i=0; i= pWord); ... 阅读全文
posted @ 2018-12-23 19:19
super行者
阅读(124)
评论(0)
推荐(0)
摘要:
#include #include using namespace std; bool checkRevStr (const char * src) { if (src == NULL) return false; const char * end = src + strlen(src) - 1; while (*src++ == *end--); retur... 阅读全文
posted @ 2018-12-23 19:18
super行者
阅读(155)
评论(0)
推荐(0)
摘要:
#include #include using namespace std; int strcmp1 (const char * a, const char * b) { int ret = 0; while (!(ret=*a-*b) && *b) { ++a; ++b; } return (ret>0)?(1):((... 阅读全文
posted @ 2018-12-23 19:17
super行者
阅读(303)
评论(0)
推荐(0)
摘要:
#include #include using namespace std; const char * findFirstLongestStr (const char * src, const char * des, unsigned int & count) { if (src==NULL || des==NULL) return NULL; int desLen = st... 阅读全文
posted @ 2018-12-23 19:16
super行者
阅读(425)
评论(0)
推荐(0)
摘要:
例如字符串aabbbc,插入字符个数后变成aa2bbb3c1 阅读全文
posted @ 2018-12-23 19:15
super行者
阅读(258)
评论(0)
推荐(0)
摘要:
#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行者
阅读(378)
评论(0)
推荐(0)
摘要:
1. 把字母替换成它后面的第4个字母。如:a->e, A->E, X->b, y->c 2. 翻转整个字符串 阅读全文
posted @ 2018-12-23 19:14
super行者
阅读(242)
评论(0)
推荐(0)
摘要:
empty() 堆栈为空则返回真 pop() 移除栈顶元素 push() 在栈顶增加元素 size() 返回栈中元素数目 top() 返回栈顶元素 阅读全文
posted @ 2018-12-23 19:13
super行者
阅读(217)
评论(0)
推荐(0)
摘要:
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行者
阅读(171)
评论(0)
推荐(0)
摘要:
#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行者
阅读(213)
评论(0)
推荐(0)
摘要:
#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行者
阅读(169)
评论(0)
推荐(0)
摘要:
#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行者
阅读(220)
评论(0)
推荐(0)
摘要:
#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行者
阅读(216)
评论(0)
推荐(0)
摘要:
#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行者
阅读(389)
评论(0)
推荐(0)
摘要:
#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行者
阅读(360)
评论(0)
推荐(0)
摘要:
#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行者
阅读(220)
评论(0)
推荐(0)
摘要:
将字符串分成两部分,前半部分按ASCII码升序排序,后半部分不变(如果字符串是奇数个,则中间的字符不变)再将前后两部分交换,最后将该字符串输出。 阅读全文
posted @ 2018-12-23 19:02
super行者
阅读(368)
评论(0)
推荐(0)
摘要:
#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行者
阅读(284)
评论(0)
推荐(0)
摘要:
#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行者
阅读(353)
评论(0)
推荐(0)
摘要:
汉字作为一个字符处理,已知:汉字编码为双字节,其中首字节<0,尾字节在0~63以外(如果一个字节是 -128 ~ 127) 阅读全文
posted @ 2018-12-23 18:59
super行者
阅读(242)
评论(0)
推荐(0)
摘要:
#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行者
阅读(579)
评论(0)
推荐(0)
摘要:
#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行者
阅读(382)
评论(0)
推荐(0)
摘要:
#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行者
阅读(132)
评论(0)
推荐(0)
摘要:
#include #include using namespace std; #define BIT(n) (0x1=0; i--) { if (c & BIT(i)) cout << "1"; else cout << "0"; } cout <<"b" << endl; } int m... 阅读全文
posted @ 2018-12-23 18:55
super行者
阅读(711)
评论(0)
推荐(0)
摘要:
#include #include using namespace std; bool checkLittleEnd (void) { union test { int a; char b; } t; t.a = 1; return (t.b==1); } int main() { if (checkLittle... 阅读全文
posted @ 2018-12-23 18:53
super行者
阅读(231)
评论(0)
推荐(0)
摘要:
【自我总结】 1.默认构造函数不仅可以是无参的,也可以是有参的,但所有参数必须指定默认值。一个类只能有一个默认构造函数。 2.什么时候调用默认构造函数? a.声明类的对象时没有括号时。如:classA objA; b.子类构造函数没有显式调用父类构造函数时 3.构造函数中的默认参数要从右向左指定。 阅读全文
posted @ 2018-12-23 18:49
super行者
阅读(3161)
评论(0)
推荐(0)
摘要:
#include #include using namespace std; class demo { public: static int i; // 这里不可以初始化非const static变量! static const int j = 1; // 1st place to initiate for const static varia... 阅读全文
posted @ 2018-12-23 18:48
super行者
阅读(472)
评论(0)
推荐(0)
摘要:
#include #include using namespace std; class demo { public: static void showObjCount(void); private: static int count; static const int j = 1; public: void funcObj(void); demo(i... 阅读全文
posted @ 2018-12-23 18:47
super行者
阅读(427)
评论(0)
推荐(0)
摘要:
class EMPTY { public: EMPTY(); //默认构造函数 EMPTY(const EMPTY &); //复制构造函数 ~EMPTY();//默认析构函数 EMPTY & operator=(const EMTPY &); //赋值运算符 EMPTY * operator&(); //取址运算符 const EMPTY * ... 阅读全文
posted @ 2018-12-23 18:46
super行者
阅读(379)
评论(0)
推荐(0)
摘要:
普通构造函数可以被隐式调用,而explicit构造函数(显式构造函数)只能被显式调用 关于隐式转换,参考:【转】这篇文章 首先, C++中的explicit关键字只能用于修饰只有一个参数的类构造函数, 它的作用是表明该构造函数是显示的, 而非隐式的, 跟它相对应的另一个关键字是implicit, 意 阅读全文
posted @ 2018-12-23 18:44
super行者
阅读(385)
评论(0)
推荐(0)
摘要:
复制构造函数应用场景: 1.一个对象以值传递的方式传入函数体 2.一个对象以值传递方式从函数返回 3.一个对象需要通过另外一个对象进行初始化 阅读全文
posted @ 2018-12-23 18:42
super行者
阅读(452)
评论(0)
推荐(0)
摘要:
如果复制的对象中引用了某个外部的内容(例如分配在堆上的数据),那么在复制这个对象的时候,让新旧两个对象指向同一个外部的内容,就是浅复制;如果在复制这个对象的时候为新对象制作了外部对象的独立的COPY,就是深复制。 深拷贝和浅拷贝主要是针对类中的指针和动态分配的空间来说的,因为对于指针只是简单的值复制 阅读全文
posted @ 2018-12-23 18:40
super行者
阅读(425)
评论(0)
推荐(0)
摘要:
A & operator= (A & b) {} A obj1; A obj2(1,2); obj1 = obj2; //这条赋值语句可理解如下: obj1.=(obj2) , 相当于obj1调用了它自己的=(A &b) 函数, 而=就是函数名。 因此obj1=obj2这句函数调用本身是有返回值的, 阅读全文
posted @ 2018-12-23 18:36
super行者
阅读(266)
评论(0)
推荐(0)
摘要:
全部模板特例化 模板中所有参数全被指定为确定的类型 部分模板特例化分两种情况 1.对部分模板参数进行特例化 2.使用具有某一特征的类型,对模板参数进行特例化 混合这两种情况的例子如下 总结: template后<>的列表中要列出没有明确指明类型的 typename 下面是一段示例代码: 下面是另一段 阅读全文
posted @ 2018-12-23 17:17
super行者
阅读(458)
评论(0)
推荐(0)
摘要:
下面代码展示通过继承方式把模板中与参数无关的代码分离出来 阅读全文
posted @ 2018-12-23 10:44
super行者
阅读(197)
评论(0)
推荐(0)

浙公网安备 33010602011771号