srand()
gives the random function a new seed, a starting point (usually random numbers are calculated by taking the previous number (or the seed) and then do many operations on that number to generate the next).
time(0)
gives the time in seconds since the Unix epoch, which is a pretty good "unpredictable" seed (you're guaranteed your seed will be the same only once, unless you start your program multiple times within the same second).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…