
c++&c
zhongweij
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
linux c++连接mysql示例
编译和连接程序 MySQL中有一个特殊的脚本,叫做mysql_config. 它会为你编译MySQL客户端,并连接到MySQL服务器提供有用的信息.你需要使用下面两个选项. 1. --libs 选项 - 连接MySQL客户端函数库所需要的库和选项. $ mysql_config --libs 2. --cflags 选项 - 使用必要的include文件的选项等等...2009-11-24 19:12:00 · 196 阅读 · 0 评论 -
c++ IO标志
1. 操纵算子这里已经添加了一个新的元素:一个称作 e n d l的操纵算子。一个操纵算子作用于流上,这种情况下,插入一新行并清空流(消除所有存储在内部流缓冲区里的还没有输出的字符) 。也可以只清空流:c o u t < < f l u s h;另外有一个基本的操纵算子把基数变为o c t (八进制),d e c (十进制)或h e x (十六进制):c o u t < <...原创 2010-01-31 21:35:33 · 369 阅读 · 0 评论 -
C++输入输出流缓冲
C++为了提供通用接口给这些流并且仍然隐藏其基本的实现,它被抽像成自己的类,叫s t r e a m b u f。每一个输入输出流都包含一个指针,指向某种s t r e a m b u f(这依赖于它是否处理标准I / O、文件、内存等等) 。我们可以直接访问s t r e a m b u f。例如,可以向s t r e a m b u f移进、移出原始字节,而不必通过输入输出流来格式化它...原创 2010-01-31 21:56:13 · 159 阅读 · 0 评论 -
C++建立自己的操纵算子
这是建立一个操纵算子的例子,这个操纵算子叫n l,它产生一个换行而不刷新这个流 #include<iostream> using namespace std; ostream &nl(ostream &os){ os << "\n" ; } int main(){ cout << "hello" <&原创 2010-01-31 22:24:21 · 170 阅读 · 0 评论 -
C++ const使用
C + +中的c o n s t默认为内部连接,也就是说,c o n s t仅在c o n s t被定义过的文件里才是可见的,而在连接时不能被其他编译单元看到。当定义一个常量(c o n s t)时,必须赋一个值给它,除非用e x t e r n作了清楚的说明: extern const bufsize; 虽然上面的e x t e r n强制进行了存储空间分配(另外还有一些情况,如取一个c o...原创 2010-02-01 13:34:47 · 136 阅读 · 0 评论 -
C++ 对私有继承成员公有化
当私有继承时,基类的所有p u b l i c成员都变成了p r i v a t e。如果希望它们中的任何一个是可 视的,只要用派生类的p u b l i c选项声明它们的名字即可。 #include <iostream> using namespace std; class base{ public: void f(){ cout << "f()"...原创 2010-02-03 17:24:03 · 303 阅读 · 0 评论 -
c++ 用“引用”而非“值”去捕获异常
如果抛出一个派生类对象而且该对象被基类的对象处理器通过值捕获到,对象会被“切片”,这就是说,随着向基类对象的传递,派生类元素会依次被割下,直到传递完成。这样的偶然性并不是所要的,因为对象的行为像基类而不象它本来就是的派生类对象(实际就是“切片”以前)。 #include <iostream> using namespace std; class base{ public: ...原创 2010-02-04 13:30:10 · 249 阅读 · 0 评论 -
c++编程思想中的编程准则(转)
1. 不要用C + +主动重写我们已有的C代码,除非我们需要对它的功能做较大的调整,(也就 是说,不破不立)。用C + +重新编译是很有价值的,因为这可以发现隐藏的错误。把一段运行 得很好的C代码用C + +重写可能是在浪费时间,除非C + +的版本以类的形式提供许多重用的机 会。 2. 要区别类的创建者和类的使用者(客户程序员)。类的使用者才是“顾客”,他们并不需 要或许也不想知道类的...原创 2010-02-04 14:11:08 · 169 阅读 · 0 评论 -
元编程示例
C++(元编程) template<int N> struct factorial { enum={value = N * factorial<N - 1>::value}; }; template<> struct factorail<0> { enum{value=1}; }; void main() { ...原创 2010-10-17 14:44:07 · 191 阅读 · 0 评论 -
zoj 3197
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3322 最小区间覆盖,排序加上贪心。 #include <iostream> #include <algorithm> #include <cstdio> using namespace std; struct SetNod...2009-09-06 00:14:00 · 130 阅读 · 0 评论 -
zoj 3196
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3321 回溯,dfs实现,注意要用long long, 9个100相乘最大数需要long long表示。 #include <iostream> #include <cstdio> using namespace std; long long a...2009-09-05 23:31:00 · 142 阅读 · 0 评论 -
zoj2876
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1875 #include <vector> #include <iostream> #include<algorithm> #include <string> #include <cstring> using...2009-09-05 16:28:00 · 166 阅读 · 0 评论 -
大数加减乘除求根源码
[code="c++"]//设计一个支持大数运算的计算器,其中乘法使用分治法求解。该计算器支持加减乘除还有开方根运算。 #include #include #include #include #include #include using namespace std; list Add(list s, list t); list Sub(list s, list t)...2009-11-29 16:11:27 · 146 阅读 · 0 评论 -
linux c++连接mysql示例
MySQL中有一个特殊的脚本,叫做mysql_config. 它会为你编译MySQL客户端,并连接到MySQL服务器提供有用的信息.你需要使用下面两个选项. 1. --libs 选项 - 连接MySQL客户端函数库所需要的库和选项. $ mysql_config --libs 2. --cflags 选项 - 使用必要的include文件的选项等等. $ m...2009-11-29 16:18:32 · 131 阅读 · 0 评论 -
zoj1019
#include <iostream> #include <cmath> using namespace std; const int SIZE = 100; int map[SIZE][SIZE]; struct{ int min; int max; char direction; }step[SIZE]; int n; int m; int...2009-12-05 14:43:00 · 114 阅读 · 0 评论 -
zoj3179
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3220 简单题,好久没写c++代码了,练习zoj,也学习c++. #include <iostream> #include <cmath> using namespace std; const int ROW = 8; const int ...2009-12-05 18:29:00 · 122 阅读 · 0 评论 -
zoj3504
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=3504 C代表有几个字母,每一行输入的16进制是每个字母的显示,每个字母有7行5列,每一行输入的5个16进制数,每个二进制数对应显示的每一列,取每个16进制数的二进制表示的后7位,如果该位为1,则显示'#',否则显示为空格。 比如第一个case的第一列7F 08 08 08 ...2009-12-05 19:27:00 · 99 阅读 · 0 评论 -
zoj1004
#include <iostream> #include <string> #include <stack> #include <fstream> using namespace std; char *pSrc = NULL; char *pDest = NULL; stack<char> s1; char res[100...2009-09-01 23:06:00 · 105 阅读 · 0 评论 -
zoj3158
对于每一行 ,都要从某一位置分成两段 ,由于不能切出0长度的一段,所 以有n - 1个选择 ,一共m行 ,就是(n - 1)m种方案 。由于问题的规模很 小 ,暴力枚举所有情况取最优解就可以了。直接用dfs即可。 #include <iostream> #include <cstdlib> #include <string> #include <...2009-09-03 22:16:00 · 105 阅读 · 0 评论 -
大数加减乘除求根源码
//设计一个支持大数运算的计算器,其中乘法使用分治法求解。该计算器支持加减乘除还有开方根运算。 #include <iostream> #include <list> #include <string> #include <cstdio> #include <cctype> #include <cmath> us...2009-09-03 23:22:00 · 235 阅读 · 0 评论 -
C++实现平方的安全方法(redis的实现)
/* Our hash table capability is a power of two */ static unsigned long _dictNextPower(unsigned long size) { unsigned long i = DICT_HT_INITIAL_SIZE; //DICT_HT_INITIAL_SIZE=4 if (size &...原创 2011-06-01 10:50:39 · 156 阅读 · 0 评论