码迷,mamicode.com
首页 >  
搜索关键字:std    ( 41627个结果
算法导论--装备线调度(升序&&降序输出)
题意就先不用讲了吧,感觉自己还没有掌握核心的东西。//心得 //怎样保持路径,递归的实现 #include #include #include #include #include using namespace std; int a[100][100];//time for station int t[100][100];//time for from Li to Lj int f[100]...
分类:其他好文   时间:2014-07-12 23:54:43    阅读次数:356
Effective C++ Item 34 区分接口继承与实现继承
接口继承和实现继承不同。在 public 继承下, derived classes 总是继承 base class 的接口 class Shape{ public: virtual void draw() const = 0; virtual void error(const std::string &msg); int objectID() const; //... }; class Rectangle: public Shape{...}; class Ellipse: public Sha...
分类:编程语言   时间:2014-07-12 23:42:27    阅读次数:251
Effective C++ Item 38 通过复合塑模出 has-a 或 is-implemented-in-terms-of
经验:在应用域,复合意味着 has-a。 在实现域,复合意味着 is-implemented-in-terms-of 示例: template //将list应用于 Set。错误做法 class Set: public std::list {...}; 解析: public 继承表示 is-a,即如果D是一种B,对B为真的每一件事,对D也应该为真。但list可以包含相同的元素,而Set不可以 纠正: template class Set{ publi...
分类:编程语言   时间:2014-07-12 23:02:43    阅读次数:369
Effective C++ Item 29 为”异常安全”而努力是值得的
经验:异常安全函数即使发生异常也不会泄漏资源或允许任何数据结构败坏。这样的函数区分为三种 可能的保证: 基本型-->发生异常,程序处于某个合法状态 强烈型-->发生异常,程序处于原先状态 不抛异常型-->承诺绝不抛出殿堂 示例: class PrettyMenu{ public: //... void changeBackground(std::istream &imgSrc); //改变背景图像 //... private: Mutex mutex; //互斥器 Image *bgI...
分类:编程语言   时间:2014-07-12 21:35:16    阅读次数:298
2013 长沙邀请赛 ADEGH 题解
HDU 4565 So Easy! 类似fib的构造 设Fn = x + y*sqrt(b) 啪啦啪啦 #include #include #include #include #include using namespace std; typedef vector vec; typedef vector mat; typedef long long ll; ll a, b,...
分类:其他好文   时间:2014-07-12 21:34:01    阅读次数:349
VS2010中使用命令行参数
在Linux下编程习惯了使用命令行参数,故使用VS2010时也尝试了一下。 新建项目,c++编写程序如下: #include #include using namespace std; int main(int argc,char*argv[]) { ifstream fin(argv[1],ios::in);//输入方式打开文件 //ifstream fin;fin.open(argv...
分类:其他好文   时间:2014-07-12 21:01:31    阅读次数:296
写代码时常见的错误
实验室有要做阶段练习题了,其中有一道改bug题:#include #include int main(int, char**) { std::vector** ppRandomData = distributeRandomInt(100); for (unsigned int i=0; i<1000; i++) { if (ppRandomData[i]) { std:...
分类:其他好文   时间:2014-07-12 19:46:35    阅读次数:223
Effective C++ Item 31 降低文件间编译依存关系
经验:支持”编译依存性最小化“的一般构想是:相依于声明式,不要相依于定义式。 基于此构想的两个手段是 Handle classes 和 Interface classes. 示例:相依于定义式 #include #include "date.h" #include "address.h" class Person{ public: Person(const std::string &name, const Data &birthday, const Address &addr); st...
分类:编程语言   时间:2014-07-12 19:39:46    阅读次数:347
hdu 1051 Wooden Sticks
简单贪心。 将所给数据从小到大进行排序,将所给零件的两数据均小于另一个零件的两数据,看做一个集合。 最后输出集合个数。#include #include #include #include #include using namespace std; struct www { int x,y; }s[5005]; int yy[5005],a,b; bool cmp(www q,w...
分类:其他好文   时间:2014-07-12 19:01:39    阅读次数:208
动态数组索引越界问题
1、在C++中,可以采用几种不同的方法创建一个某种类型T的对象的数组。3种常用的方法如下: #define N 10 //数组的长度N在编译时已知 T static_array[10]; int n = 20; //数组的长度n是在运行时计算的 T* dynamic_array = new T[n]; std::vector vector_array; //数组的长度可以在运...
分类:其他好文   时间:2014-07-12 17:57:42    阅读次数:131
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!