Which One Is the Best Strategy?
Another interesting problem I met in statistic is: suppose we flip a coin which has probability 0.7 to be head again and again and two people choose two different sequences of length 3 (e.g. THH). The people whose sequence appears first wins. If you're allowed to choose first …
Performance Tips for C++
Performance
-
If there is some block of useless code, the compile is smart enough to ignore it and thus speed up the program.
-
Use the option
-O2
to generate optimized code when you are ready to publish your code. -
Define variables only when needed to avoid the overhead of creating …
Lambda Function in C++11
Lambda Function
Check [here[(https://github.com/dclong/cearn/tree/master/lambda) for illustrative examples for the following discussions.
-
When capture variables, you can define new variables in the
[]
of a lambda expression. For example, if a lambda function need the sum of two double variablex
andy
, you …
Rescue Linux from GUI Freezing
The kernel of Linux is usually very stable, but the existing free desktop environments are craps. Amongs these desktop environments I tried (Gnome, Xfce, LXDE and so on), none is even close to the desktop environments in Windows and Mac. I do not require desktop environments in Linux to be …
Initializing Variables in C++
{}
is more powerful than()
and thus is preferred over()
. You should use always use{}
except for a few cases where()
is necessary. For example, if you want to create a vector of length 1000, you have to usevector<int>(1000);
instead of
vector<int> {1000};
which create a vector …