Here is the script to replace all strings in a file.
How to Change the IP Address of the SVN Server in Checked-out Project?
1
find . -name entries | xargs perl -pi -e 's/OLD_IP/NEW_IP/'
How to Use STL Sort?
By now, the fastest comparison sorting algorithm is \(Ο(N\log N)\). The sort()
function in STL implemented with an optimized quicksort, which is always \(O(N\log N)\).
Here is an example:
How to Use "Pair" in STL?
In Python, we have tuple, and in Java, we have Map, but in C++, the language itself doesn’t contain anything equivalent. Nevertheless, we can use STL - the Standard Template Library - to construct the data structure.
Of course, we can construct this by ourself, and it’s not complex, but as we will see, with “pair” we can make it easier and simpler.
This is an example:
How to Record Time in C++?
To record the time your program costs, you can use the function clock()
, that is defined in <ctime>
.
Here is an example showing how to use this function:
Binary-Search Tree Template
This is a Binary-Search Tree template written by Leon.
POJ 2418 Hardwood Species
This problem can be solved by at least 4 methods:
- Quick Sort
- Binary Search Tree
- Trie and Depth First Search
- Map
POJ 2002 Squares
Here is my pseudo code:
count <-- 0
for each edge( two points) do
find the possible other two points to construct a square, there will be two pairs.
for each pair of points do
use binary search or hash to check if both points are given
if both are given then count <-- count+1
return count
VC6.0 Has a Stack Overflow
When VC6.0 breaks down due to a stack overflow, sometimes you can adjust the stack allocations to get around this problem.
Project->Settings->Link->Category->Output
Write the bytes you need in Stack allocations->Reserve.