add srand before rand
Merge pull request #83 from fanzeyi/fix-rand

Init random generator before calling rand()