摘要:#include #include #include #include #include using namespace std; int main() { stack> s; queue> q; // the default container of queue is deque for (int i = 0; i < 10; i++) { ...
阅读全文
摘要:#include #include using namespace std; // rever letters of a string char * strRevert1 (char * src) { if (src == NULL) return NULL; int len = strlen(src); for (int i=0; i= pWord); ...
阅读全文
摘要:#include #include using namespace std; int strcmp1 (const char * a, const char * b) { int ret = 0; while (!(ret=*a-*b) && *b) { ++a; ++b; } return (ret>0)?(1):((...
阅读全文
摘要:#include #include using namespace std; // not using string library char * rightLoop1 (char * src, int n) { if (src==NULL) return NULL; char * p = src; while (*p++); int len = p-1-sr...
阅读全文
摘要:#include #include using namespace std; #define BIT(n) (0x1 T set_bit (T value, T bit_n) { value |= BIT(bit_n); return value; } template T clear_bit (T value, T bit_n) { value &= ~BIT(b...
阅读全文
摘要:#include #include using namespace std; bool checkLittleEnd (void) { union test { int a; char b; } t; t.a = 1; return (t.b==1); } int main() { if (checkLittle...
阅读全文
摘要:#include #include using namespace std; class demo { public: static int i; // 这里不可以初始化非const static变量! static const int j = 1; // 1st place to initiate for const static varia...
阅读全文
摘要:#include #include using namespace std; class Person { public: virtual void print(void) { cout << "I am a Person!" << endl; } }; class Chinese: public Person { public: virt...
阅读全文
摘要:#include #include using namespace std; class MyString { public: MyString(const char * s=NULL) { if (s == NULL) { m_string = new char[1]; m_string[...
阅读全文