2011年2月17日

life: zz 关于爱情

摘要: 发信人: BTpig (猪猡猡), 信区: Astrology标 题: 就说一个:喜欢对方的理由发信站: 水木社区 (Wed Feb 16 10:40:38 2011), 站内昨晚看电视,幸福魔方《她大我16岁》相差16岁的爱情,女方明显的非常成熟,性格也不错,尤其说话的时候淡定平和的语调,很喜欢想起来我喜欢巨蟹的一个理由:我若情绪不好或心中有怒的时候,说话像利刀,很不留情面;且语气很激动,看上去就一副怒不可遏的状态;巨蟹纵使心里有再多怨怒,语气还是平和的,看上去也风平浪静许多我喜欢、欣赏并想拥有这份淡定从容;希望是表面+内心的发信人: biteshark (你带走了我的魂), 信区: Pie 阅读全文

posted @ 2011-02-17 23:36 cutepig 阅读(328) 评论(0) 推荐(0) 编辑

Atl: COM IDispatch interface client

摘要: #include <atlstr.h> //CStringint _tmain(int argc, _TCHAR* argv[]){ CoInitialize(NULL); CComPtr<IDispatch> m_pFSO; CComVariant strFolder(_T("C:\\11111") ); LPCOLESTR lpszName = L"CreateFolder"; m_pFSO.CoCreateInstance ( L"Scripting.FileSystemObject" );#if 1 HRESULT hRes = m_pFSO.Invoke1 阅读全文

posted @ 2011-02-17 15:19 cutepig 阅读(304) 评论(0) 推荐(0) 编辑

c++: lazy evaluation

摘要: #include <vector>#include <assert.h>struct Expression;struct Num{ Num(size_t n, int i) { data.resize(n, i); } Num& operator=(Expression& exp); void print() const { for(size_t i=0; i<data.size();i++) printf("%d ", data); printf("\n"); } std::vector <int> data;};stru 阅读全文

posted @ 2011-02-17 15:13 cutepig 阅读(379) 评论(0) 推荐(0) 编辑

c++: simple signal lib

摘要: //typedef function0 <int> FunctionType;#include <iostream>#include <boost/shared_ptr.hpp>#include <vector>#include <algorithm>using namespace boost;using namespace std;typedef int RType;typedef RType (*FunctionType)();class MySlot{public: bool IsValid() {return fun_!=0; 阅读全文

posted @ 2011-02-17 14:26 cutepig 阅读(360) 评论(0) 推荐(0) 编辑

tool: count line count of files in a folder

摘要: #include <stdio.h>#include <windows.h>//#include <hash_map>//#include <string>char line[10000];FILE *fpW = 0; //count lineFILE *fpW_Date = 0; //for srch file within some datelong gnchar=0,gnline=0;int hours_before = 0;char destFolder[MAX_PATH]={0};//std::hash_map<std::st 阅读全文

posted @ 2011-02-17 14:23 cutepig 阅读(418) 评论(0) 推荐(0) 编辑

alg_DP: LCS ( longest common substring )

摘要: #include <stdio.h>#include <stdlib.h>#include <string.h>//Run By LCS.// O (m*n)// DP implementationconst char* GetSameString (char const* ArgA,char const* ArgB, int *pN){int nA = strlen(ArgA);int nB = strlen(ArgB);if (!nA || !nB) return 0;int* CompareArr=new int[nB];int max=0,maxJ= 阅读全文

posted @ 2011-02-17 14:22 cutepig 阅读(246) 评论(0) 推荐(0) 编辑

c: investigate float

摘要: #include <stdio.h>#include <math.h>#include <assert.h>double f(int x){ return 1.0/x;}void Test1(){ double a,b; int i; a=f(10); b=f(10); i = a==b; printf("%d\n", i);}void Test2(){ double a,b,c; int i; a=f(10); b=f(10); c=f(10); i = a==b; printf("%d\n", i);}template <typename T> 阅读全文

posted @ 2011-02-17 14:19 cutepig 阅读(279) 评论(0) 推荐(0) 编辑

alg: atof

摘要: #include <stdio.h>#include <math.h>int Reverse(int n){ int m=0; for( ; n>0; n/=10 ) m = m*10 + (n%10); return m;}bool IsNumber(char c){ return c>='0' && c<='9';}double Atof(const char *s, char **stopPos){ int sign = 1; double l1 = 0.0; double l2 = 0.0; int sign2 = 1; do 阅读全文

posted @ 2011-02-17 14:17 cutepig 阅读(218) 评论(0) 推荐(0) 编辑

C++: RVO( return value optimization)

摘要: #include <stdio.h>class RVO{public: RVO() { printf("I am in constructor %d\n", this); } RVO (const RVO& c_RVO) { printf ("I am in copy constructor %d\n", this); } ~RVO() { printf ("I am in destructor %d\n", this); } RVO& operator=(const RVO& rhs) { printf ("I am in operator %d = %d 阅读全文

posted @ 2011-02-17 14:16 cutepig 阅读(3284) 评论(0) 推荐(0) 编辑

alg: replace the substring

摘要: #include <string>#include <iostream>//replace the substring l to r for source string s, and put result in dvoid replace(const std::string& s,const std::string& l,const std::string& r,std::string& d){ size_t i=0, n=s.length(), nl=l.length(); while( 1 ) { size_t pos = s.f 阅读全文

posted @ 2011-02-17 14:15 cutepig 阅读(328) 评论(0) 推荐(0) 编辑

C++: Ctor

摘要: // A: // no default ctor// with copy ctorclass A{public: explicit A(int) {}};//B:// no default ctor// no ctor from int// with copy ctorclass B: public A{};int main(){ //A a; //fail A a(1); //ok A a2(a); //ok //B b(1); //fail //B b; //fail B *pb = (B*)0; B b(*pb); //OK} 阅读全文

posted @ 2011-02-17 14:12 cutepig 阅读(469) 评论(0) 推荐(0) 编辑

C++: TypeList

摘要: #include <stdio.h>#include <typeinfo.h>//// TypeList//template <class T, class U>struct TypeList{ typedef T Head; typedef U Tail;};struct NullType{};#define TYPELIST_1(T1) TypeList<T1, NullType>#define TYPELIST_2(T1, T2) TypeList<T1, TYPELIST_1(T2) >#define TYPELIST_3( 阅读全文

posted @ 2011-02-17 14:09 cutepig 阅读(1486) 评论(0) 推荐(0) 编辑

alg_trie: count Word frequency

摘要: #include <stdio.h>#include <stdlib.h>#include <string.h>#define TREE_WIDTH 256#define WORDLENMAX 128// count Word frequencystruct trie_node_st { int count; struct trie_node_st *next[TREE_WIDTH];};static struct trie_node_st root={0, {NULL}};static char *spaces=" \t\n/.\"\'()";static 阅读全文

posted @ 2011-02-17 14:08 cutepig 阅读(296) 评论(0) 推荐(0) 编辑

alg: 反转字符串中的单词顺序

摘要: #include <stdio.h>//2. 反转字符串或反转段落中的单词顺序;void reverse(const char *s, //source string int n, //length of s char *d) //destination{ int i=n-1; int di=0; while(i>=0) { //find a word int si=i; for(; si>=0; i--) { if(s[si]==' ') break; } //copy to d for(int j=si; j<=i; j++) d[di++] 阅读全文

posted @ 2011-02-17 14:04 cutepig 阅读(311) 评论(0) 推荐(0) 编辑

alg: 首尾相连的珠子

摘要: #include <stdio.h>/*感觉稍微难点的三个:1)设计一个栈结构,满足一下条件:min,push,pop操作的时间复杂度为O(1)3)设计一个系统处理词语搭配问题,比如说 中国 和人民可以搭配,则中国人民 人民中国都有效。要求: 1)系统每秒的查询数量可能上千次; 2)词语的数量级为10W; 3)每个词至多可以与1W个词搭配 当用户输入中国人民的时候,要求返回与这个搭配词组相关的信息.*//*2)一串首尾相连的珠子(m个),有N种颜色(N《=10),设计一个算法,取出其中一段,要求包含所有N中颜色,并使长度最短。并分析时间复杂度与空间复杂度。time: O(m)spa 阅读全文

posted @ 2011-02-17 14:01 cutepig 阅读(1454) 评论(1) 推荐(0) 编辑

C++: Impl of RTTI

摘要: #include <stdio.h>#define CHECK(x) {if(!(x)) printf("ERROR " #x " @Line %d\n", __LINE__);}struct TypeInfo{ char* m_name; const TypeInfo* m_parent; TypeInfo(char* name, const TypeInfo* parent) :m_name(name), m_parent(parent) { }};class A{ static TypeInfo typeInfo_a;public: static const TypeInf 阅读全文

posted @ 2011-02-17 13:57 cutepig 阅读(1098) 评论(0) 推荐(0) 编辑

alg_problem: number_of_disc_intersections

摘要: Given an array A of N integers we draw N discs in a 2D plane, such that i-th disc has center in (0,i) and a radius A[i]. We say that k-th disc and j-th disc intersect, if and k-th and j-th discs have at least one common point. Write a function int number_of_disc_intersections(int[] A); which giv 阅读全文

posted @ 2011-02-17 12:14 cutepig 阅读(568) 评论(1) 推荐(0) 编辑

C++: public/protected/private inheritance

摘要: class A{ public: int a; private: int b; protected: int c;};// // public inheritance:// - data access type not change// - B cannot access A's private member//class B: public A{ public: void test() { a = 1; //b = 1; //Fail c = 1; }};// // protected inheritance:// - data access type: public -&g 阅读全文

posted @ 2011-02-17 12:12 cutepig 阅读(789) 评论(0) 推荐(0) 编辑

C++: member function pointer for SomeClass

摘要: #include <stdio.h>class SomeClass {public: void some_member_func(int x, char *p) { printf("In SomeClass"); };};class DerivedClass : public SomeClass {public:// If you uncomment the next line, the code at line (*) will fail!// void some_member_func(int x, char *p) { printf("In DerivedClass"); 阅读全文

posted @ 2011-02-17 12:10 cutepig 阅读(243) 评论(0) 推荐(0) 编辑

ML近三年在CVPR比较流行被应用的技术有哪些?

摘要: 发信人: mlmonster (bishop), 信区: AI标 题: ML近三年在CVPR比较流行被应用的技术有哪些?发信站: 水木社区 (Sun Feb 13 01:31:10 2011), 站内是不是以下几个:nonparametric bayesian/LDA structure learning of graphical modelsparse representation/compressive sensinggaussian processmanifold learning请大家各抒己见,说说自己觉得比较有应用前景的技术吧?发信人: mlmonster (bishop), 信区: 阅读全文

posted @ 2011-02-17 08:16 cutepig 阅读(433) 评论(0) 推荐(0) 编辑

导航