rand().. 隨機取一值..
但怎樣能以電腦的時間為索引....取一亂數值
希望大家幫忙..謝謝!
--
◎ [1;31m龍 [32m貓 [33m資 [34m訊 [35m天 [36m地 [0m( [1mbbs.mgt.ncu.edu.tw [0m)
◎[ [1;33;46mlailee [0m]來自: 140.115.226.72
--
◎ [1;31m龍 [32m貓 [33m資 [34m訊 [35m天 [36m地 [0m( [1mbbs.mgt.ncu.edu.tw [0m)
◎[ [1;33;46mNoey [0m]來自: mb2.mgt.ncu.edu.tw
Macro that initializes random number generator
Declaration:
void randomize(void);
Remarks:
randomize initializes the random number generator with a random
value.
Because randomize is implemented as a macro that calls the time
function prototyped in TIME.H, you should include TIME.H when you use
this routine.
Return Value: None
See Also:
rand random srand
Example:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(void)
{
int i;
randomize();
printf("Ten random numbers from 0 to 99\n\n");
for(i=0; i<10; i++)
printf("%d\n", rand() % 100);
return 0;
}
--
[1;36m華梵大學 [1;32m青橄欖
[1;35mEmail: HCW...@bbs.hfu.edu.tw
[0m
--
[1;34m * 來源: 華梵大學‧阿育王 BBS <203.64.33.5> telnet://bbs.hfu.edu.tw/ [m
[1;34m * 作家: ㊣ [From: bird.hfu.edu.tw] [m
--
※ Origin: 程式設計樂園 ◆ From: h192.s245.ts.hinet.net