基本概念: 1. 操作符重载:C++支持对某个操作符赋予不同的语义 2. new操作符:申请内存,调用构造函数关于c++ new操作符的重载你知道c++的new操作符和operator new的区别么?也许你还会问,他们有区别吗?当你写下面这样的代码时,string *pa = new stri.....
分类:
编程语言 时间:
2014-08-11 14:21:02
阅读次数:
221
题目链接:uva 11427 - Expect the Expected
题目大意:你每天晚上都会玩纸牌,每天固定最多玩n盘,每盘胜利的概率为p,你是一个固执的人,每天一定要保证胜局的比例大于p才会结束游戏,若n局后仍没有,就会不开心,然后以后再也不完牌,问说你最多会玩多少个晚上。
解题思路:当j/i ≤ p时有dp(i-1,j) (1-p) + dp(i-1, j-1)
p,其他d...
分类:
其他好文 时间:
2014-08-11 00:21:01
阅读次数:
208
#include #include #include #include #include using namespace std;struct node{ char msg[20]; int a,b;};struct cmp{ bool operator()(const node ...
分类:
其他好文 时间:
2014-08-10 21:17:20
阅读次数:
214
Overflow
Write a program that reads an expression consisting of two non-negative integer and an operator. Determine if either integer or the result of the expression is too large to be rep...
分类:
其他好文 时间:
2014-08-09 21:35:29
阅读次数:
321
看下面一个表示string对象的类:// 一个很简单的string类class string {public: string(const char *value); ~string(); ... // 没有拷贝构造函数和operator=pr...
分类:
其他好文 时间:
2014-08-09 18:14:08
阅读次数:
186
Divide Two IntegersDivide two integers without using multiplication, division and mod operator.不用* 、/、%来做除法。只能加减了啊亲!算法思路:一个一个加上去必超时,例如dividend = Integ...
分类:
其他好文 时间:
2014-08-08 20:59:36
阅读次数:
186
模版代码:#include#include#includeusing namespace std;struct node{ friend bool operator qi; for(i = 0; i , greater >qi2; for(i = 0; i qn; node...
分类:
其他好文 时间:
2014-08-08 17:54:56
阅读次数:
246
今天在调试一个页面的时候遇到一个问题,在IE9下运行得很好的脚本,在IE8里打开的时候弹出错误:expected identifier, string or number,按照经验,应该是定义对象的时候最后一个属性末尾跟了逗号,但检查一遍后没发现有这种情况,后来仔细看了一下报错的位置,发现有定义json对象属性时,属性名没有用引号括起来,于是加了上去再试,问题解决了。
综上所述,当出现expec...
分类:
Web程序 时间:
2014-08-08 12:41:54
阅读次数:
277
一.序列和关联非共有函数
所有标准库共有函数 (构造,相关属性,迭代器,插入与删除,比较,swap)
其中operator>,operator>=,operator均不适用于priority_queue
顺序容器和关联容器共有函数
(1) 序列容器都提供5种相同的构造方法;关联容器都提供3种相同的构造方法
(2) 还有insert插入函数(序列容器有3个相同版本的插入。关联容...
分类:
其他好文 时间:
2014-08-07 13:15:30
阅读次数:
189
Effictive c++中将要让operator =()返回*this的引用,原因说是为了连环赋值,测试一下,发现不是如此,参考http://blog.csdn.net/nodeathphoenix/article/details/38146421class Test {public: Te...
分类:
其他好文 时间:
2014-08-07 12:15:49
阅读次数:
173