原创 pku acm 1065

//貪心算法 #include <iostream> #include <cstdio> #include <list> #include <algorithm> using namespace std; typedef pair<i

原创 pku acm 1095

Trees Made to Order #include <iostream> #include <cstdio> #include <string> using namespace std; const int LEN = 30;

原创 pku acm 1061

解題思想: (x + step * m) % L = (y + step * n) % L 則(x - y + step * (m - n) ) % L == 0  || ( y - x + step * (n - m)) % L ==

原创 while(cin)的理解

Jery最早的意圖是支持一個iostream class object的純量測試,像這樣: if ( cin )... 爲了讓cin能夠求得一個真假值,Jerry首先爲它定義一個conversion運算符,即operator int()。

原创 Operator new函數

operator new void* operator new (std::size_t size) throw (std::bad_alloc); void* operator new (std::size_t size, cons

原创 new 與 operator new,placement new

"placement new"? 它到底是什麼東東呀?我也是最近幾天才聽說,看來對於C++我還差很遠呀!placement new 是重載operator new的一個標準、全局的版本,它不能被自定義的版本代替(不像普通的operator

原创 pku acm 1099

解題報告:   1 2 3 4 5 6 7 8 9 10 11 12 13 14 1     H       H               2     |       |               3 H - O - H - O -

原创 pku acm 1014

/* Source Code Problem: 1014 User: xudacheng06 Memory: 284K Time: 0MS Language: C++ Result: Accepted Source Cod

原创 指向類的數據成員和函數指針

  指向類成員的指針 在C++語言中,可以定義一個指針,使其指向類成員或成員函數,然後通過指針來訪問類的成員。這包括指向屬性成員的指針和指向成員函數的指針。 à 指向數據成員的指針 在C++語言中,可以定義一個指針,使其指向類成員。當屬性

原创 pku acm 1029

#include <iostream> #include <cstdio> #include <algorithm> using namespace std; int flg[1001];//標記硬幣:0:初始狀態;1:可疑的;2

原创 pku acm 1035

//Spell checker #include <iostream> #include <cstdio> #include <string> #include <set> using namespace std; set<string

原创 pku acm 1018

題目: http://poj.org/problem?id=1018 解題報告: 1)方式一(對應maxbp) 分爲兩個集合S和S1: 1:初始情況下S[ (65535, 0) ], S1 [ ]爲空       輸入第一批數據後:(1

原创 pku acm 1017

#include <iostream> #include <cstdio> #include <algorithm> using namespace std; int main() { freopen("in.txt","r",st

原创 C++ Utilities四(Uninitialized memory的使用)

以下三個函數定義爲頭文件memory中,下面是其可能的實際代碼。代碼來源於《The C++ Standard Library》 namespace std { template<class ForwIter,class T> void

原创 字符特性char_traits定義,及其特化版本char_traits,char_traits

// iosfwd standard header #if _MSC_VER > 1000 #pragma once #endif #ifndef _IOSFWD_ #define _IOSFWD_ #include <cst