- 博客(15)
- 资源 (9)
- 收藏
- 关注
原创 自增运算符重载
#include#include #include using namespace std;class A{ public: A(int a_, char ch_):a(a_),ch(ch_){} void print(){ cout<<"a "<<a<<" ch "<<ch<<endl; } A & operator++() {
2012-11-30 23:24:36 702
原创 给定一个数组,求x和y,使得abs(x+y)最接近零
// 给定一个数组,求x和y,使得abs(x+y)最接近零// 要求时间复杂度尽量小// 先排序:#include#include #include using namespace std;void getZeroPoint(int *p, int n, int&a,int &b){ if (p[0] <=0 && p[n-1]<=0) {
2012-11-30 22:06:24 1547
转载 传纸条message
传纸条message (noip 2008 第三题)(massage.pas/c/cpp)【问题描述】小渊和小轩是好朋友也是同班同学,他们在一起总有谈不完的话题。一次素质拓展活动中,班上同学安排做成一个m行n列的矩阵,而小渊和小轩被安排在矩阵对角线的两端,因此,他们就无法直接交谈了。幸运的是,他们可以通过传纸条来进行交流。纸条要经由许多同学传到对方手里,小渊坐在矩阵的左上角,坐标(
2012-11-30 20:56:20 1141
原创 动态规划:数字三角形
////Number Triangles (出处:IOI '94)//// 如下所示为一个数字三角形://// 7// 3 8// 8 1 0// 2 7 4 4// 4 5 2 6 5//// 请编一个程序计算从顶至底的某处的一条路径,使该路径经过的数字总和最大。////>每
2012-11-30 16:17:11 2624
原创 不均匀分布随机数产生均匀分布随机数
http://hi.baidu.com/wxmsona/item/9a964b1d9110d911e3f986b5有一个函数random(),该函数只能返回0或者1;该函数以概率p返回1, 1-p的概率返回0.; 要求1. 一个函数randomUpdate(),2. randomUpdate()可以任意调用random()函数;3.randomUpdate()函数只能返
2012-11-30 15:38:27 3622
原创 根据已知0-1均匀随机数产生器,构造新的随机数产生器
// 有一个函数fun能返回0和1两个值,返回0和1的概率都是1/2,// 问怎么利用这个函数得到另一个函数fun2,使fun2也只能返回0和1,且返回0的概率为0.3,返回1的概率为0.7。 #include #include int fun(){ return rand()%2;}int myfun(){ int sum; int i;
2012-11-30 13:11:15 2967
原创 编辑距离:动态规划【用最少的字符操作将字符串A 转换为字符串B】
//// 设A 和B 是2 个字符串。要用最少的字符操作将字符串A 转换为字符串B。//这里所说的字符操作包括 //(1)删除一个字符; //(2)插入一个字符;//(3)将一个字符改为另一个字符。//将字符串A变换为字符串B 所用的最少字符操作数称为字符串A到B 的编辑距离,记为 d(A,B)。//试设计一个有效算法,对任给的2 个字符串A和B,计算出它们的编辑距离d
2012-11-30 11:25:04 15568 2
原创 哈希表【自己实现】
#include #include #include #include #include using namespace std;typedef unsigned int UINT;int const N=1024;class Node{public: char *cstr; Node *next; Node(){cstr=NU
2012-11-29 11:24:47 755
原创 to be done【STL】
reverse(a.begin(),a.end())random_shuffle(a.begin(),a.end());replace(v.begin(),v.begin()+3,0,9);copy(dVector.begin(), dVector.end(), front_inserter(dList));fstreamstringstreamback_insert_it
2012-11-28 13:26:40 423
转载 istringstream用法
http://www.cppblog.com/mythma/archive/2005/11/03/913.html 今天在论坛里看到这样一个问题:要求将字符串 "mallid=310103123456\ntermno=139654785231\norder=00003995\ngcode=0000130\npaydate=20051031\nname=\ncardno=52480002
2012-11-28 12:52:54 906
原创 【stl】copy读入文件|插入迭代器
#include #include #include #include #include #include #include #include using namespace std;int main(){ vectora; ifstream os("c:\\a.txt"); back_insert_iterator > it(a
2012-11-28 11:43:18 624
转载 google全程面试题目【转】
http://www.mitbbs.com/article_t/JobHunting/31828487.html发信人: maxq (zf), 信区: JobHunting标 题: google全程面试题目,顺求安慰。。。发信站: BBS 未名空间站 (Tue Mar 22 00:34:25 2011, 美东)经过了三个月的断断续续的面试和准备,最近一阵抓了很多时间努力准
2012-11-28 11:32:05 533
转载 copy绝版应用【转】
STL笔记(3) copy()之绝版应用我选用了一个稍稍复杂一点的例子,它的大致功能是:从标准输入设备(一般是键盘)读入一些整型数据,然后对它们进行排序,最终将结果输出到标准输出设备(一般是显示器屏幕)。这是一种典型的处理方式,程序本身具备了一个系统所应该具有的几乎所有的基本特征:输入 + 处理 + 输出。你将会看到三个不同版本的程序。第一个是没有使用STL的普通C++程序,你将会
2012-11-28 11:29:00 576
原创 back_insert_iterator用法
#include int main(){ int a[10]={1,2,3,4,5,6,7,8,9,0,}; vectord(5,0); copy(a,a+10,ostream_iterator(cout," ")); cout<<endl; copy(d.begin(),d.end(),ostream_iterator(cout," ")); cout<<en
2012-11-28 11:20:55 3136 2
原创 过桥问题【经典笔试问题】
#include #include #include int CrossBridge(int n, int *p);int cmp(const void*p1, const void *p2){ return *(int*)p1-*(int*)p2;}int main(){ int *p; int n; printf("enter the g
2012-11-13 20:36:27 805
相关向量机(RVM)论文6篇
2011-12-20
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人