饮茶喝酒需注意

http://www.kugz.net/thread-187320-1-2.html
1、饮茶有那些好处?振精神、增记忆、除疲劳、抗肿瘤、抗衰老、助减肥。
2、哪种茶的保健功能最强?排列顺序是:绿茶、花茶、红茶。
3、哪些人不宜饮茶?孕妇、妇女经期及浦乳期、患失眠、便秘、贫血、溃疡病、肝病、高血压、发热病人和献血后的人,均不宜饮茶。
4、 饮茶有哪十忌?忌空腹饮茶、烫茶、冷茶、浓茶、睡前饮茶、早起饮茶、饭后立即饮茶,冲泡时期过长的茶,饭前饮茶和茶水服药。

Install office 2007 in ubuntu

http://samanathon.com/how-to-install-microsoft-office-2007-in-ubuntu-9-04/

Uninstall Previous Versions Of Wine

For some odd reason, Office 2007 will not run on a version of Wine above 1.1.14. For that reason, if you currently have Wine installed, uninstall it by follow these steps:

How to find IP address under linux

Type the following command at a shell prompt:

ifconfig -a | perl -ne 'if ( m/^\s*inet (?:addr:)?([\d.]+).*?cast/ ) { print qq($1\n); exit 0; }'

Recover grub menu after installing windows

Follow the step to recover grub bootloader:
1. Boot with Ubuntu Live CD
2. Open gnome-terminal
Give the commands:
3. sudo grub
then it shows grub> like this
grub>find /boot/grub/stage1
it’ll give a output like this (hd0,7) 7 is here for example, itĺl be number of ur partition.
grub>root (hd0,7)
grub>setup (hd0)
grub>quit

install windows 7 from usb drive

http://kmwoley.com/blog/?p=345

Step 1: Format the Drive
The steps here are to use the command line to format the disk properly using the diskpart utility. [Be warned: this will erase everything on your drive. Be careful.]

vi命令

(转载)
进入vi的命令
Vi   filename    打开或新建文件,并将光标置于第一行首
Vi   +n   filename 打开文件,并将光标置于第n行首
Vi   +    filename  打开文件并将光标置于最后一行首
Vi   +/pattern filename 打开文件,并将光标置于一个与pattern匹配的串处
Vi   filename .. Filename  打开多个文件,依次进行编辑

What is the "Named Constructor Idiom"?

A technique that provides more intuitive and/or safer construction operations for users of your class.

The problem is that constructors always have the same name as the class. Therefore the only way to differentiate between the various constructors of a class is by the parameter list. But if there are lots of constructors, the differences between them become somewhat subtle and error prone.

With the Named Constructor Idiom, you declare all the class's constructors in the private or protected sections, and you provide public static methods that return an object. These static methods are the so-called "Named Constructors." In general there is one such static method for each different way to construct an object.

Problems with inline functions in C++

(From http://)

Besides the problems associated with inline expansion in general, inline functions as a language feature may not be as valuable as they appear, for a number of reasons:

    * Often, a compiler is in a better position than a human to decide whether a particular function should be inlined. Sometimes the compiler may not be able to inline as many functions as the programmer indicates.
    * An important point to note is that the code (of the inline function) gets exposed to its client(the calling function).

Bubble Sort

The Bubble sort has a worst-case running time of Θ(n^2).

//compare the consecutive numbers, larger one sinks to the bottom
void bubbleSort(int *a)
{
// int temp;
  for(int j = 0; j < arraysize; j++) 
  { 
    for( int i = 0; i < arraysize - j - 1;i++ )
    { 
       if( a[i] > a[i+1] ) 
      {swap(a[i], a[i+1]);} 
      }
  }
}

Heapsort

“Like merge sort, but unlike insertion sort, heapsort’s running time is O(n*lg(n)). Like insertion sort, but unlike merge sort, heapsort sorts in place: only a constant number of array elements are stored outside the input array at any time. Thus, heapsort combines the better attribute of the two sorting algorithms …” [Introduction to Algorithms]

void heapSort(int *a)
{
    for(int i = arraySize; i > 1; --i)
    {
        for(int k = 0; k < i; ++k)
        {
            // compare each element with its parent
            // if the child is begger than its parent
            // then swap them
            // keep doing this until reaching the root
            while((a[k] > a[k/2]) && (k > 0))
            { 
                swap(a[k], a[k/2]); 
                k = k/2; 
            }
        }
        // After the for loop, the largest is put at a[0]
        // then put the largest to the end of the array
        // and find the largest of the rest in the same way
        swap(a[0], a[i-1]);
    }
}

Merge Sort

The merge sort has a worst case running time of Θnlg(n).

Insertion Sort

Insertion sort has a worst-case running time of Θ(n^2).
void insertionSort(int *a, int n)
{
    for (int j = 1; j < n; ++j)
    {
        int key = a[j];

        // Insert A[j] into the sorted sequence A[0, 1,...,j-1]
        int i = j-1;
        while ((i >= 0) && (key < a[i]))
        {
            a[i+1] = a[i];
            --i;
        }
        a[i+1] = key;
    }
}

Memory Allocation in C++

C++ provides two ways to allocate and free unconstructed, raw memory:

1. The allocator class, which provides type-aware memory allocation. This class supports an abstract interface to allocating memory and subsequently using that memory to hold objects.
2. The library operator new and operator delete functions, which allocated and free raw, untyped memory of a requested size.

C++ also provides various ways to construct and destroy objects in raw memory:

C++: this指针的含义及用法

(From http)
1. this指针是一个隐含于每一个成员函数中的特殊指针。它指向正在被该成员函数操作的那个对象。
2. 当对一个对象调用成员函数时,编译程序先将对象的地址赋给this指针,然后调用成员函数,每次成员函数存取数据成员时,由隐含使用this指针。
3. 当一个成员函数被调用时,自动向它传递一个隐含的参数,该参数是一个指向这个成员函数所在的对象的指针。
4. 在C++中,this指针被隐含地声明为: X *const this,这意味着不能给this 指针赋值

Inline functions in C++

(From http)
Inline functions
Inline functions are functions where the call is made to inline functions. The actual code then gets placed in the calling program.
Inline functions eliminate function-call overhead. The programmer uses the key word inline to advise the compiler to generate function code in line (when possible ) to minimize function calls. The compiler could choose to ignore the inline advice.
The inline qualifier should be sued only with small, frequently used functions.
Member functions defined in a class definition are automatically inlined. The compiler reserves the right not to inline any function.